2011-08-19 80 views

回答

0

您可以設置一個監聽器上的 「click」 事件所需的行爲。事情是這樣的:

textView.setOnClickListener(new OnClickListener() { 
    public void onClick(View v) { 
     v.setBackgroundColor(Color.GREEN); 
    } 
}); 

如果要取消選擇TextView當你在一個新的點擊,只是改變了珍貴選擇TextView的背景顏色。

Android TextView的API here

希望它能幫助:d

+0

是的,感謝dude.it很好,很簡單。 – Akshay

0

試試這個

text.setFocusable(true); 

text.requestFocus(); 
+0

我已經嘗試過了,但已經無法正常工作。 – Akshay

0
int blue = 0xff0000ff; 
int red = 0xffff0000; 
text.setBackgroundColor(blue); 
text.setTextColor(red); 
+0

它也可以工作謝謝。 – Akshay

0

你有沒有嘗試過這樣的:

TextView tv = (TextView) findVieById(R.id.my_textview); //replacing my_textview with the correct resource id 
tv.setSelectAllOnFocus(true); 
相關問題