Essayez ce code
public class YourActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
((TextView) findViewById(R.id.textView)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Do your stuff
}
});
}
@Override
public void onPause() {
super.onPause();
}
@Override
protected void onResume() {
super.onResume();
}
}
Voici votre disposition
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="Do you want to see" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/textView2"
android:text="...more?" />
</RelativeLayout>
EDIT après commentaire
Il faut donc utiliser la classe SpannableString et ClickableSpan, comme ceci
SpannableString string = new SpannableString("YourStringHere");
ClickableSpan clickHandler = new ClickableSpan() {
@Override
public void onClick(View v) {
//do your stuff here
}
@Override
public void updateDrawState(TextPaint tp) {
super.updateDrawState(tp);
tp.setUnderlineText(false);
}
};
//x and y are the start and end of the clickable substring
string.setSpan(clickHandler, x, y, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
TextView tv = (TextView) findViewById(R.id.your_text_view);
tv.setText(string);
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.textView.setHighlightColor(Color.TRANSPARENT);
J'espère que cela vous aidera ! ;-)