Android Button color changing on onClick?

前端 未结 6 784
礼貌的吻别
礼貌的吻别 2020-12-16 22:38

I am facing a problem .

I have two Button object.

ButtonA ButtonB

Requirement:-

When ever I press

6条回答
  •  醉梦人生
    2020-12-16 23:09

    buttoncolor.xml

     
       
           
           
           
      
    

    Now use like below:

    b1 = (Button) findViewById(R.id.b1);
    b1.setOnClickListener(new OnClickListener() {
    
        @Override
        public void onClick(View arg0) {
             b2.setBackgroundDrawable(getResources().getDrawable(R.drawable.whatever));
        }
    });
    
    b2 = (Button) findViewById(R.id.b2);
    b2.setOnClickListener(new OnClickListener() {
    
        @Override
        public void onClick(View arg0) {
             b1.setBackgroundDrawable(getResources().getDrawable(R.drawable.whatever));
        }
    });
    

提交回复
热议问题