I have created a listview. and there I also did the drag n drop of items. I want on which item mouse touched that text should be highlighted.(For example U open the Google & if put the mouse on Google then it highlit the text Google in small letters) I wanna same on my list items TextView items. How can开发者_如何转开发 I do it. Please answer me. Thanks
If you're stuck on the highlighting text in a TextView part, here's an example of that, borrowing heavily from Highlight Text in TextView or WebView.
public class Main extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView myTextView = (TextView)findViewById(R.id.my_textview);
myTextView.setText(myTextView.getText(), TextView.BufferType.SPANNABLE);
Spannable text = (Spannable)myTextView.getText();
text.setSpan(new BackgroundColorSpan(0xFFFFFF00), 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
myTextView.setText(text);
}
}
If instead, you just want to set the background color of the TextView, take a look at android TextView: setting the background color dynamically doesn't work.
精彩评论