java - Android HorizontalScrollView doesn't work with EditText -


so have android app outputs ascii art equivalent type in, "hello world" to

  _          _ _                            _     _   | |__   ___| | | ___   __      _____  _ __| | __| |  | '_ \ / _ \ | |/ _ \  \ \ /\ / / _ \| '__| |/ _` |  | | | |  __/ | | (_) |  \ v  v / (_) | |  | | (_| |  |_| |_|\___|_|_|\___/    \_/\_/ \___/|_|  |_|\__,_| 

being it's formatted , needs stay formatted, want horizontal scrolling edittext put in. tried make 1 didn't work well... here's java:

edittext medittext = (edittext) findviewbyid(r.id.text_status_id); horizontalscrollview mscrollview = (horizontalscrollview) findviewbyid(r.id.scroller_id); @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     init(); } private void loaddoc(){     intent intent = getintent();     string message = intent.getstringextra(mainactivity.extra_message);     string letter;     edittext textview = new edittext(this);     typeface courier = typeface.createfromasset(getassets(),"courier_prime.ttf");     textview.settextsize(20);     textview.settypeface(courier);     setcontentview(textview);     string value;     string toprint;     int textlength = message.length();     for(int = 0; <= 14; i++){         for(int j = 0; j < textlength; j++){             letter = message.substring(j,j+1).touppercase(locale.getdefault());             value = letter + i;             toprint = isometric.get(value);             textview.append(toprint);             if(j == textlength-1){                 textview.append("\n");             }         }     } }  private void init() {     loaddoc();     scrolltobottom(); }  private void scrolltobottom() {     mscrollview.post(new runnable() {         public void run() {             medittext.sethorizontallyscrolling(true);             medittext.setmovementmethod(new scrollingmovementmethod());             mscrollview.smoothscrollto(0, medittext.getbottom());         }     }); }  @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.display_message, menu);     return true; }  @override public boolean onoptionsitemselected(menuitem item) {     // handle action bar item clicks here. action bar     // automatically handle clicks on home/up button, long     // specify parent activity in androidmanifest.xml.     int id = item.getitemid();     if (id == r.id.action_settings) {         return true;     }     return super.onoptionsitemselected(item); } 

and here's xml:

<horizontalscrollview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/scroller_id" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#333333" android:fillviewport="true" android:scrollbars="horizontal">  <linearlayout     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:orientation="horizontal">      <edittext         android:id="@+id/text_status_id"         android:layout_width="0dip"         android:layout_height="fill_parent"         android:layout_gravity="center"         android:layout_weight="1.0"         android:textcolor="#cccccc"         android:textsize="35sp" /> </linearlayout> </horizontalscrollview> 

every time try run it, application stops ("unfortunately, asciigen has stopped.") have no idea i'm doing wrong. here's logcat.

10-02 19:31:46.830: d/dalvikvm(864): not late-enabling checkjni (already on) 10-02 19:31:48.210: i/dalvikvm(864): not find method android.view.viewgroup.onnestedscrollaccepted, referenced method android.support.v7.internal.widget.actionbaroverlaylayout.onnestedscrollaccepted 10-02 19:31:48.210: w/dalvikvm(864): vfy: unable resolve virtual method 12212: landroid/view/viewgroup;.onnestedscrollaccepted (landroid/view/view;landroid/view/view;i)v 10-02 19:31:48.210: d/dalvikvm(864): vfy: replacing opcode 0x6f @ 0x0000 10-02 19:31:48.210: i/dalvikvm(864): not find method android.view.viewgroup.onstopnestedscroll, referenced method android.support.v7.internal.widget.actionbaroverlaylayout.onstopnestedscroll 10-02 19:31:48.210: w/dalvikvm(864): vfy: unable resolve virtual method 12218: landroid/view/viewgroup;.onstopnestedscroll (landroid/view/view;)v 10-02 19:31:48.210: d/dalvikvm(864): vfy: replacing opcode 0x6f @ 0x0000 10-02 19:31:48.230: i/dalvikvm(864): not find method android.support.v7.internal.widget.actionbaroverlaylayout.stopnestedscroll, referenced method android.support.v7.internal.widget.actionbaroverlaylayout.sethideoncontentscrollenabled 10-02 19:31:48.230: w/dalvikvm(864): vfy: unable resolve virtual method 9779: landroid/support/v7/internal/widget/actionbaroverlaylayout;.stopnestedscroll ()v 10-02 19:31:48.230: d/dalvikvm(864): vfy: replacing opcode 0x6e @ 0x000e 10-02 19:31:48.340: i/dalvikvm(864): not find method android.content.res.typedarray.getchangingconfigurations, referenced method android.support.v7.internal.widget.tinttypedarray.getchangingconfigurations 10-02 19:31:48.340: w/dalvikvm(864): vfy: unable resolve virtual method 393: landroid/content/res/typedarray;.getchangingconfigurations ()i 10-02 19:31:48.340: d/dalvikvm(864): vfy: replacing opcode 0x6e @ 0x0002 10-02 19:31:48.340: i/dalvikvm(864): not find method android.content.res.typedarray.gettype, referenced method android.support.v7.internal.widget.tinttypedarray.gettype 10-02 19:31:48.340: w/dalvikvm(864): vfy: unable resolve virtual method 415: landroid/content/res/typedarray;.gettype (i)i 10-02 19:31:48.340: d/dalvikvm(864): vfy: replacing opcode 0x6e @ 0x0002 10-02 19:31:48.370: i/dalvikvm(864): not find method android.content.res.resources.getdrawable, referenced method android.support.v7.internal.widget.resourceswrapper.getdrawable 10-02 19:31:48.370: w/dalvikvm(864): vfy: unable resolve virtual method 356: landroid/content/res/resources;.getdrawable (ilandroid/content/res/resources$theme;)landroid/graphics/drawable/drawable; 10-02 19:31:48.370: d/dalvikvm(864): vfy: replacing opcode 0x6e @ 0x0002 10-02 19:31:48.370: i/dalvikvm(864): not find method android.content.res.resources.getdrawablefordensity, referenced method android.support.v7.internal.widget.resourceswrapper.getdrawablefordensity 10-02 19:31:48.370: w/dalvikvm(864): vfy: unable resolve virtual method 358: landroid/content/res/resources;.getdrawablefordensity (iilandroid/content/res/resources$theme;)landroid/graphics/drawable/drawable; 10-02 19:31:48.370: d/dalvikvm(864): vfy: replacing opcode 0x6e @ 0x0002 10-02 19:31:49.120: i/choreographer(864): skipped 34 frames!  application may doing work on main thread. 10-02 19:31:49.140: d/gralloc_goldfish(864): emulator without gpu emulation detected. 10-02 19:31:52.230: i/choreographer(864): skipped 64 frames!  application may doing work on main thread. 10-02 19:31:53.700: i/choreographer(864): skipped 98 frames!  application may doing work on main thread. 10-02 19:31:54.410: d/androidruntime(864): shutting down vm 10-02 19:31:54.410: w/dalvikvm(864): threadid=1: thread exiting uncaught exception (group=0xb2a12ba8) 10-02 19:31:54.460: e/androidruntime(864): fatal exception: main 10-02 19:31:54.460: e/androidruntime(864): process: com.dumpong.asciigen, pid: 864 10-02 19:31:54.460: e/androidruntime(864): java.lang.runtimeexception: unable instantiate activity componentinfo{com.dumpong.asciigen/com.dumpong.myfirstapp.displaymessageactivity}: java.lang.nullpointerexception 10-02 19:31:54.460: e/androidruntime(864):  @ android.app.activitythread.performlaunchactivity(activitythread.java:2121) 10-02 19:31:54.460: e/androidruntime(864):  @ android.app.activitythread.handlelaunchactivity(activitythread.java:2245) 10-02 19:31:54.460: e/androidruntime(864):  @ android.app.activitythread.access$800(activitythread.java:135) 10-02 19:31:54.460: e/androidruntime(864):  @ android.app.activitythread$h.handlemessage(activitythread.java:1196) 10-02 19:31:54.460: e/androidruntime(864):  @ android.os.handler.dispatchmessage(handler.java:102) 10-02 19:31:54.460: e/androidruntime(864):  @ android.os.looper.loop(looper.java:136) 10-02 19:31:54.460: e/androidruntime(864):  @  android.app.activitythread.main(activitythread.java:5017) 10-02 19:31:54.460: e/androidruntime(864):  @ java.lang.reflect.method.invokenative(native method) 10-02 19:31:54.460: e/androidruntime(864):  @ java.lang.reflect.method.invoke(method.java:515) 10-02 19:31:54.460: e/androidruntime(864):  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 10-02 19:31:54.460: e/androidruntime(864):  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 10-02 19:31:54.460: e/androidruntime(864):  @ dalvik.system.nativestart.main(native method) 10-02 19:31:54.460: e/androidruntime(864): caused by: java.lang.nullpointerexception 10-02 19:31:54.460: e/androidruntime(864):  @ android.app.activity.findviewbyid(activity.java:1884) 10-02 19:31:54.460: e/androidruntime(864):  @ com.dumpong.myfirstapp.displaymessageactivity.<init>(displaymessageactivity.java:295) 10-02 19:31:54.460: e/androidruntime(864):  @ java.lang.class.newinstanceimpl(native method) 10-02 19:31:54.460: e/androidruntime(864):  @ java.lang.class.newinstance(class.java:1208) 10-02 19:31:54.460: e/androidruntime(864):  @ android.app.instrumentation.newactivity(instrumentation.java:1061) 10-02 19:31:54.460: e/androidruntime(864):  @ android.app.activitythread.performlaunchactivity(activitythread.java:2112) 10-02 19:31:54.460: e/androidruntime(864):  ... 11 more 10-02 19:31:58.730: i/process(864): sending signal. pid: 864 sig: 9 

any appreciated, have no idea i'm doing wrong.

replace

edittext medittext = (edittext) findviewbyid(r.id.text_status_id); horizontalscrollview mscrollview = (horizontalscrollview) findviewbyid(r.id.scroller_id); 

with

edittext medittext; horizontalscrollview mscrollview; 

and initialize inside init() method

private void init() { medittext = (edittext) findviewbyid(r.id.text_status_id); mscrollview = (horizontalscrollview) findviewbyid(r.id.scroller_id); loaddoc(); scrolltobottom(); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -