我設置textview背景等於透明,現在我想在代碼中改變它的背景。 當點擊mybtn(這是一個按鈕)改變textview背景,它是怎麼做到的?如何在代碼中設置textview的背景?
代碼:
Button btn = (Button) findViewById(R.id.btn_dialog);
btn.setBackgroundColor(color.transparent);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
TextView txt = (TextView) findViewById(R.id.txt);
txt.setBackgroundColor(??????);
Toast.makeText(getBaseContext(), "this test is ok!", Toast.LENGTH_SHORT).show();
}
});
原諒我,我編輯我的代碼 由於我瓦納setBackgroungColor我的TextView 請幫我 –
+1準確的解決方案,用於設置背景圖片。 –
@PareshMayani感謝所有..。 。 –