हैलो मैंने टेक्स्टव्यू में कुछ टेक्स्ट सेट किया है।स्पैन किए गए स्ट्रिंग को स्पैन करने योग्य कैसे परिवर्तित करें
TextView tweet = (TextView) vi.findViewById(R.id.text);
tweet.setText(Html.fromHtml(sb.toString()));
तब मैं Spannble
में TextView
का पाठ परिवर्तित करने के लिए की जरूरत है। तो मैं इस तरह किया:
Spannable s = (Spannable) tweet.getText();
मैं इसे Spannable
बदलने की आवश्यकता है क्योंकि मैं एक समारोह में TextView
पारित कर दिया:
private void stripUnderlines(TextView textView) {
Spannable s = (Spannable) textView.getText();
URLSpan[] spans = s.getSpans(0, s.length(), URLSpan.class);
for (URLSpan span : spans) {
int start = s.getSpanStart(span);
int end = s.getSpanEnd(span);
s.removeSpan(span);
span = new URLSpanNoUnderline(span.getURL());
s.setSpan(span, start, end, 0);
}
textView.setText(s);
}
private class URLSpanNoUnderline extends URLSpan {
public URLSpanNoUnderline(String url) {
super(url);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
}
यह कोई त्रुटि/चेतावनी दिखाता है।
java.lang.ClassCastException: android.text.SpannedString cannot be cast to android.text.Spannable
मैं Spannble में TextView की SpannedStringt/पाठ कैसे परिवर्तित कर सकते हैं: लेकिन एक रनटाइम त्रुटि फेंक? या क्या मैं फ़ंक्शन के अंदर SpannedString के साथ एक ही कार्य कर सकता हूं?
भयानक जब यूआई लोग कोई रेखांकन के साथ लिंक बनाने का निर्णय लेते हैं? एक ही चीज़ के माध्यम से जा रहे हैं। – portfoliobuilder