姬長信(Redy)

在Android中以编程方式更改ImageView的图像


当我以编程方式更改图像时,它会在最初在布局文件中设置的旧图像上显示新图像?

这是我的布局文件的片段:


    

    

 

以及设置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);

                       }
                   });

我错过了什么?