Android TextView append SpannableString forcing java.lang.RuntimeException on Nexus 7 -
i have serious problem crashes app.
i'm loading text in app textview. parts of text clickable , should call activity - works fine devices. unfortunatelly not work on nexus 7 devices , don't know why.
this stacktrace google:
java.lang.runtimeexception: can't create handler inside thread has not called looper.prepare() @ android.os.handler.(handler.java:197) @ android.os.handler.(handler.java:111) @ android.widget.editor$userdictionarylistener.(editor.java:3836) @ android.widget.editor.(editor.java:192) @ android.widget.textview.createeditorifneeded(textview.java:8475) @ android.widget.textview.settext(textview.java:3611) @ android.widget.textview.settext(textview.java:3554) @ android.widget.textview.append(textview.java:3277) @ android.widget.textview.append(textview.java:3267) [...some app methods not relevant problem...]
the java code:
final string text = displayedtext; spannablestring link = makelinkspan(displayedtext, new view.onclicklistener() { @override public void onclick(view v) { //call activiy } }); textview.append(link);
the stacktrace tells me call looper.prepare() don't know where... i'm loading data in asynctask. layout inflated inside doinbackground method , textview child of it. don't see reasson why problem affects nexus 7 users , not devices. emulator nexus 7 preset working without problem
any ideas how solve this? :d
you need inflate layout on main thread. can this->
runonuithread(new runnable() { @override public void run() { // todo inflate layout & set textview's text here } });
Comments
Post a Comment