views:

52

answers:

1

Hi, I have a TextView .I am using it like a link by using

t2.setMovementMethod(LinkMovementMethod.getInstance()) 

for this textview in .java files so that it blinks when I clicks, but I want the color of textview to be changed when clicked. I used

t2.setLinkTextColor(0xff0000)

but does not work. my code is as follows:

public class TextHyperLink extends Activity implements OnClickListener
{ 
/** Called when the activity is first created. */ 
    TextView t2; 

    @Override public void onCreate(Bundle savedInstanceState) 
    { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main); 
        t2 = (TextView) findViewById(R.id.text2);                                                                      t2.setMovementMethod(LinkMovementMethod.getInstance()); 
        t2.setLinkTextColor(0xff0000); 
        t2.setOnClickListener(this);

    }

    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        if(arg0==t2)
        {

        //  t2.setColor()
    //      System.out.println("Link TextViewwwwww");
        }
    }

    }

my xml

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/text2"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="@string/link_text_manual"
    android:textColorLink="#FFFF00"

    />  

Can any one help me in solving this issue.?

+1  A: 

The obvious answer is that you aren't calling setLinkTextColor() in the onClick method and when you add it if you want the color to change it has to be a different color than 0xff000.

BrennaSoft