Android:控件的对象修改控件的值

TextView

private TextView textView;
...
textView =(TextView)findViewById(R.id.textView);
textView.setText("set text success");

控制:

<TextView 
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="#ff0000"
        android:text="old text"
        />

ImageView

 imageViewId1 =(ImageView)findViewById(R.id.imageViewId1);
 imageViewId1.setImageResource(R.drawable.logo_small);
 imageViewId1.setScaleType(ScaleType.CENTER);
<ImageView 
    android:id="@+id/imageViewId1"
    android:layout_width="120dp"
    android:layout_height="120dp"
    android:src="@drawable/pic1"
    android:scaleType="fitXY"
    android:background="#ff0000"
    />
posted @ 2014-06-10 22:39  tinyphp  Views(987)  Comments(0Edit  收藏  举报