android - Cannot change the text of TextView on Button Press -


what want every time user goes 1 text in textview (q) textview (nm) shows number @ user is. in brief, every time value of variable changes, want set value text @ texview (nm) . but, here shows error.

the button doesn't work. what's wrong?

logcat

04-01 19:54:55.901: e/androidruntime(32078): fatal exception: main 04-01 19:54:55.901: e/androidruntime(32078): java.lang.nullpointerexception 04-01 19:54:55.901: e/androidruntime(32078):    @ com.dreamgoogle.gihf.quotes$1.onclick(quotes.java:43) 04-01 19:54:55.901: e/androidruntime(32078):    @ android.view.view.performclick(view.java:3524) 04-01 19:54:55.901: e/androidruntime(32078):    @ android.view.view$performclick.run(view.java:14194) 04-01 19:54:55.901: e/androidruntime(32078):    @ android.os.handler.handlecallback(handler.java:605) 04-01 19:54:55.901: e/androidruntime(32078):    @ android.os.handler.dispatchmessage(handler.java:92) 04-01 19:54:55.901: e/androidruntime(32078):    @ android.os.looper.loop(looper.java:137) 04-01 19:54:55.901: e/androidruntime(32078):    @ android.app.activitythread.main(activitythread.java:4476) 04-01 19:54:55.901: e/androidruntime(32078):    @ java.lang.reflect.method.invokenative(native method) 04-01 19:54:55.901: e/androidruntime(32078):    @ java.lang.reflect.method.invoke(method.java:511) 04-01 19:54:55.901: e/androidruntime(32078):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:816) 04-01 19:54:55.901: e/androidruntime(32078):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:583) 04-01 19:54:55.901: e/androidruntime(32078):    @ dalvik.system.nativestart.main(native method) 

the problem nm never bound component in view. thats reason npe here:

nm.settext(string.valueof(i)) ; 

add class:

private void varset() {         next = (imagebutton) findviewbyid(r.id.next);         previous = (imagebutton) findviewbyid(r.id.previous);         copytext = (imagebutton) findviewbyid(r.id.copy);         q = (textview) findviewbyid(r.id.quotes);         nm = (textview) findviewbyid(r.id.your_id); // bound nm here id         str = new string[] {                 "in order succeed, desire success should greater fear of failure.",                 "a successful man 1 can lay firm foundation bricks others have thrown @ him.",                 "success not final, failure not fatal: courage continue counts.",                 "try not become man of success. rather become man of value.",                  };      }; 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -