当我以编程方式更改图像时,它会在原来在布局文件中设置的旧图像之上显示新图像?
这是我的布局文件的一个片段:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="39dp"
android:gravity="center_vertical" >
<ImageView
android:id="@+id/qStatusImage"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_margin="5dp"
android:background="@drawable/thumbs_down"
/>
<TextView
android:id="@+id/grp_child"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="@color/radio_colors"
android:textStyle="normal"
android:background="@color/grey"
/>
</LinearLayout>
以及设置imageView的代码:
@Override
public View getChildView(final int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
//Answers
if(answersGroup != null)
answersGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// int index = answersGroup.indexOfChild(findViewById(answersGroup.getCheckedRadioButtonId()));
qImageView = (ImageView) V.findViewById(R.id.qStatusImage);
if(ans ==0 || ans == 5){
// qSV.setImageResource(0);
qImageView.setImageResource(R.drawable.thumbs_up);
}
else
qImageView.setImageResource(R.drawable.thumbs_down);
}
});
我想念什么?
image.setImageResource(R.drawable.icon_dot1);