public class AccountSetupActivity extends Activity implements OnClickListener {
ImageButton fbButton;
@Override
public void onClick(View v) {
Toast.makeText(this, "FB clicked", Toast.LENGTH_SHORT).show();
Drawable fbLight = getResources().getDrawable(R.drawable.fborange);
fbButton.setBackgroundDrawable(fbLight);
// fbButton.setBackgroundResource(0);
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.setupaccounts);
fbButton = (ImageButton) findViewById(R.id.fbButton);
fbButton.setOnClickListener(this);
}
}
答案 0 :(得分:1)
尝试使用此行代替设置图像:
fbButton.setImageDrawable(fbLight);
我认为您打算设置最前面的图像,但是设置背景图像
答案 1 :(得分:0)
试试这个
buttonName.setBackgroundResource(R.drawable.imageName);
答案 2 :(得分:0)
试试这个:
fbButton.setImageResource(R.drawable.fborange)