Tweet o = tweets.get(position);
TextView tt = (TextView) v.findViewById(R.id.toptext);
//TextView bt = (TextView) v.findViewById(R.id.bottomtext);
EditText bt =(EditText)findViewById(R.id.bottomtext);
bt.setText(o.author);
Spannable spn = (Spannable) bt.getText();
spn.setSpan(new StyleSpan(android.graphics.Typeface.BOLD_ITALIC)
, 0, 100, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
//bt.setText(o.author);
tt.setText(o.content);
我在我的Android應用程序中設置twitter數據。我想使用Spannable使字體粗體和斜體,但它不起作用,出現錯誤。我該怎麼做?spannable on android for textView
它給出的意外停止錯誤。通常代碼工作,但我想使字體粗體。 ıtgıves此錯誤。 – baran 2013-02-12 19:41:39
請發佈LogCat輸出,但例外。最有可能你嘗試跨越文本結束應用跨度 - 使用實際長度而不是100 – Asahi 2013-02-12 19:53:31
這種方法可能會有所幫助https://stackoverflow.com/a/44255840/3496570 – Nepster 2017-05-30 07:24:01