2011-08-19 81 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); 
相关问题