how to replace/change image button programmatically android

前端 未结 4 563
天命终不由人
天命终不由人 2021-02-08 21:12

I have an image button on my view which i need to change after user interaction. I dont find nothing like myImageButton.setDrawable Here is my xml for the button i

相关标签:
4条回答
  • 2021-02-08 21:49

    Use

    setImageResource(R.drawable.btn_stop);

    0 讨论(0)
  • 2021-02-08 21:51

    You can use

    setImageResource for the image button
    
    0 讨论(0)
  • 2021-02-08 21:51

    Use this:

    myImageButton.setImageResource(R.drawable.btn_stop);
    
    0 讨论(0)
  • 2021-02-08 22:02
    ImageButton = (ImageButton)findViewById(R.id.stopButton);
    btn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.btn_stop, 0, 0, 0);
    
    0 讨论(0)
提交回复
热议问题