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);

    }

}

最佳答案

尝试使用此行来设置图像:

        fbButton.setImageDrawable(fbLight);


我认为您打算设置最前面的图像,但是要设置背景图像

10-07 21:13