单击按钮切换 TextView 背景
Switching TextView backgorund on button click
有没有办法在我按下按钮时切换 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
}
});
}
我觉得很简单
textView.setBackgroundResource(R.drawable.your_image);
有没有办法在我按下按钮时切换 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
}
});
}
我觉得很简单
textView.setBackgroundResource(R.drawable.your_image);