按钮单击时切换TextView backgorund

时间:2015-07-22 20:35:14

标签: java android android-drawable

按下按钮时有没有办法切换TextView背景?

背景在drawable文件夹中,我需要这样的东西:

public void ChangeBG(){
    Button mybutton = (Button) findViewById(R.id.button1);
    mybutton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            //SET  R.DRAWABLE.BG2  AS BACKGROUND

        }
    });
}

1 个答案:

答案 0 :(得分:2)

我认为它很简单

 textView.setBackgroundResource(R.drawable.your_image);