Guys this is the sample text: "I want this [ option1 / option2 ] clickable."
What i what to happen is when user click an option( or a word) i will save the clicked word to a variable. How to make that options clickable?
Thanks for any help..
Guys this is the sample text: "I want this [ option1 / option2 ] clickable."
What i what to happen is when user click an option( or a word) i will save the clicked word to a variable. How to make that options clickable?
Thanks for any help..
This is a blog having example same as you need It helped me a lot. Link To Blog
Code from Blog how can you do this.
In Your Main Activity set Links This way.
mTextSample = (TextView) findViewById(R.id.text1);
text = "<html>Visit my blog <a href=\"http://sherifandroid.blogspot.com\">mysite</a> or run the <a href=\"sherif-activity://myactivity?author=sherif&nick=king\">myactivity</a> callback</html>";
mTextSample.setText(Html.fromHtml(text));
mTextSample.setMovementMethod(LinkMovementMethod.getInstance());
To get the Parameters :
TextView mTextSample = (TextView) findViewById(R.id.text);
mTextSample.setText(getIntent().getData().getQueryParameter("author"));
mTextSample = (TextView) findViewById(R.id.text1);
mTextSample.setText(getIntent().getData().getQueryParameter("nick"));
In Manifest Declare your second Activity as :
<activity android:label="@string/app_name" android:name="sherif.android.linkify.example.TestActivity">
<intent-filter> <data android:scheme="sherif-activity" android:host="myactivity"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
can't do that easily without checking inside the text view in an onTouch
event which part of the textview is touched (involves checking x,y position of touch inside textview )
to do what you want to do easily use 2 textboxes and set 2 different onClickListener
check this out for more detail http://developer.android.com/guide/topics/ui/ui-events.html on how to set clicklisteners