0

i have created a textview with underline text like this

     <TextView
    android:id="@+id/label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text = "@string/underline_text"
    android:clickable = "true"
    android:focusable = "true"
    android:focusableInTouchMode="true"
    android:isScrollContainer="true"
    android:textColor = "#0000FF"
    android:layout_marginLeft = "48dp"

/>  

with string mapped to

    <string name="underline_text"><u>Hello</u></string>

i am getting underline text i am not being able to get focus while touching it or while scrolling between views .

Please anyone have any idea how to get this done.

Thanks

Rishi
  • 3,499
  • 8
  • 35
  • 54
  • how do you know that it is not getting focused – Sherif elKhatib Jul 29 '11 at 11:47
  • cause when i get focus in button it gets orange color to show indication that its in focus mode this functionality i want in my textview as well cause i am making it clickable,right now its get cliecked and do the job but user didnt get any focused effect on it while clicking it. – Rishi Jul 29 '11 at 11:53
  • @Rishi: `TextView` is not meant to be clicked like `Button` so it won't show this effect by default. You can of course do it yourself. See @Sherif's answer. – Mudassir Jul 29 '11 at 12:09

2 Answers2

2
setOnFocusChangeListener(new OnFocusChangeListener(){
        @Override
        public void onFocusChange(View arg0, boolean arg1) {
            // TODO Auto-generated method stub
            arg0.setBackgroundColor(Color.YELLOW);
        }
});
Sherif elKhatib
  • 45,786
  • 16
  • 89
  • 106
0

I think, you are trying to create a hyperlink, if so, please refer to the following links;

Community
  • 1
  • 1
Mudassir
  • 13,031
  • 8
  • 59
  • 87
  • i tried linkify , i am trying to make a text which looks like hyperlink and clickable as well ,when user click it you it will show focused effect which is what i am not getting . – Rishi Jul 29 '11 at 11:58
  • @Rishi: By focus, are you expecting something like Windows? – Mudassir Jul 29 '11 at 12:08
  • by focus i mean it will show any user noticeable change it its properties so that one can understand it it getting pressed or got focus.(like the whole text will get any border on getting focus or anything else just to stand it out fron the normal mode) – Rishi Jul 29 '11 at 12:24