int flag = 0;
final ImageButton IB_PullDown = new ImageButton(context);
// Bitmap a=null;
// IB_PullDown.setButtonDrawable(new BitmapDrawable(a));
IB_PullDown.setBackgroundResource(R.drawable.xl_jiantou);
IB_PullDown.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// IB_PullDown.setBackgroundResource(R.drawable.pulldown_button_image);
if (flag == 0) {
// TODO Auto-generated method stub
IB_PullDown.setBackgroundResource(R.drawable.sq_jiantou);
ll_AirItem.setVisibility(View.VISIBLE);
flag = 1;
} else {
IB_PullDown.setBackgroundResource(R.drawable.xl_jiantou);
ll_AirItem.setVisibility(View.GONE);
flag = 0;
}
}
});
代码很简单,你们使用的时候将图片和对象换成自己的即可。