Android項目——網絡圖片查看器


效果-=--------------》
加入包




<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    tools:context="${relativePackage}.${activityClass}" >

 

    <!-- widthheigh設置0   weight表示 渲染的權重     當不指定值時代表的 優先級    默認是 值越大 優先級越低 -->

    <com.loopj.android.image.SmartImageView

        android:layout_weight="1000"

        android:id="@+id/siv"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent" />

 

    <EditText

        android:singleLine="true"

        android:text="http://img0.bdstatic.com/img/image/shouye/dengni47.jpg"

        android:id="@+id/et"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:hint="請輸入圖片路徑" /><!-- 提示 -->

 

    <Button

        android:onClick="click"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:hint="瀏覽圖片"/>

 

</LinearLayout>

-------------------------------------------------------------------------------------------------------------

public class MainActivity extends Activity {

   private EditText et_path;

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        et_path = (EditText) findViewById(R.id.et);

    }

   

    public void click(View view)

    {

       SmartImageView siv = (SmartImageView) findViewById(R.id.siv);

       siv.setImageUrl(et_path.getText().toString().trim(), R.drawable.ic_launcher, R.drawable.ic_launcher);

    }

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章