आप क्या कर सकते हैं एक कस्टम के रूप में नीचे ClickableSpan
,
class MyCustomSpannable extends ClickableSpan
{
String Url;
public MyCustomSpannable(String Url) {
this.Url = Url;
}
@Override
public void updateDrawState(TextPaint ds) {
// Customize your Text Look if required
ds.setColor(Color.YELLOW);
ds.setFakeBoldText(true);
ds.setStrikeThruText(true);
ds.setTypeface(Typeface.SERIF);
ds.setUnderlineText(true);
ds.setShadowLayer(10, 1, 1, Color.WHITE);
ds.setTextSize(15);
}
@Override
public void onClick(View widget) {
}
public String getUrl() {
return Url;
}
}
और किसी गतिविधि या यूआरएल को खोलने के लिए उपयोग अपने onClick()
पैदा करते हैं। मैं WebView
में एक यूआरएल लोड करने के लिए एक डेमो जोड़ रहा हूं।
String text = "http://www.google.co.in/";
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
MyCustomSpannable customSpannable = new MyCustomSpannable(
"http://www.google.co.in/"){
@Override
public void onClick(View widget) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(customSpannable.getUrl()));
startActivity(intent);
}
};
stringBuilder.setSpan(customSpannable, 0, text.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
textView.setText(stringBuilder, BufferType.SPANNABLE);
textView.setMovementMethod(LinkMovementMethod.getInstance());
स्रोत
2012-06-20 08:49:29
मुझे लगता है कि आप की जाँच करनी चाहिए: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/text/Link.html http://developer.android.com/ संसाधन/लेख/विकिनोट्स- linkify.html –
ठीक है, मुझे लगता है कि आप यही चाहते हैं [एंड्रॉइड कस्टम हाइपरलिंक्ड टेक्स्ट व्यू] (http://webcache.googleusercontent.com/search?q=cache:http://www। orangeapple.org/) –
@Lalit Poptani यह मदद की मुझे धन्यवाद – user609239