我想设置在ListView中有一个图片和按钮,点击按钮图片更换,可是发现,各种错。代码如下,有做过的朋友帮忙下。
public View getView(int position, View convertView, ViewGroup parent) {
myview = layoutinflater.inflate(R.layout.main_item, null);
final TextView textView=(TextView) myview.findViewById(R.id.textview_number);
final TextView textView_main=(TextView) myview.findViewById(R.id.textview_weiguan);
textView_user=(TextView) myview.findViewById(R.id.textview_user);
textView_main.setText(title);
final Button Button_Main_weiguan=(Button)myview.findViewById(R.id.Button_01);
final ImageView imageview_Main_01 =(ImageView)myview.findViewById(R.id.imageview_01);
imageview_Main_user =(ImageView)myview.findViewById(R.id.imageview_user);
final LinearLayout linearLayout_Mian_Tu=(LinearLayout)myview.findViewById(R.id.linearLayout3);
final LinearLayout linearLayout_Mian_user=(LinearLayout)myview.findViewById(R.id.linearLayout5);
MyAnimation ma=new MyAnimation(linearLayout_Mian_user,context);
ma.load_start_Animation(Animation);
        Button_Main_weiguan.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
//这句开始出错
imageview_Main_user.setBackgroundResource(R.drawable.a);
textView_user.setText("一点也不好玩");
Message message = new Message();
message.what = 1;
handler.sendMessage(message);
}
        });//         linearLayout_Mian_Tu.setOnClickListener(new GoToMediaPlayer());
textView.setText("目前有"+position+"人在围观");
return myview;
}
public Handler handler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
ListView_Main.invalidateViews();
break;
}
super.handleMessage(msg);
}
};
    }