android - onClickListener couses Crash with TextView -


im trying create simple application no luck want preform action if touches list view if i'm not adding onclicklistener ok java:

        listview mylistview = (listview)findviewbyid(r.id.listviewoptions);     final arraylist<string> optionsarray = new arraylist<string>();        final arrayadapter<string> arrayadapter;       arrayadapter = new arrayadapter<string>(this,android.r.layout.simple_list_item_1,optionsarray);      for(int =1 ; < 3 ; i++)     {         optionsarray.add("1");         arrayadapter.notifydatasetchanged();     }      mylistview.setadapter(arrayadapter);     mylistview.setclickable(true);     mylistview.setfocusable(true);      onclicklistener onclicklistener = new onclicklistener() {      public void onclick(view v) {         // todo auto-generated method stub      } };  mylistview.setonclicklistener(onclicklistener); 

xml:

<listview android:layout_height="wrap_content"  android:layout_width="fill_parent"  android:layout_weight="1"  android:id="@+id/listviewoptions"  android:clickable="true"> </listview> 

thanks

log:

e/androidruntime(  232): caused by: java.lang.runtimeexception: don't call setonclicklistener adapterview. want setonitemclicklistener instead e/androidruntime(  232):    @ android.widget.adapterview.setonclicklistener(adapterview.java:750) e/androidruntime(  232):    @ com.resume.resume.oncreate(resume.java:52) e/androidruntime(  232):    @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1123) e/androidruntime(  232):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2364) e/androidruntime(  232):    ... 11 more i/process (   52): sending signal. pid: 232 sig: 3 i/dalvikvm(  232): threadid=7: reacting signal 3 e/dalvikvm(  232): unable open stack trace file '/data/anr/traces.txt': permission denied w/activitymanager(   52): launch timeout has expired, giving wake lock! w/activitymanager(   52): activity idle timeout historyrecord{439114c0 com.resume/.resume} 

you need learn @ logcat output... had done you'd see following:

e/androidruntime( 4280): java.lang.runtimeexception: unable start activity componentinfo{org.rjh.testproj/org.rjh.testproj.mainactivity}:  java.lang.runtimeexception: don't call setonclicklistener adapterview. want setonitemclicklistener instead e/androidruntime( 4280):        @ android.app.activitythread.performlaunchactivity(activitythread.java:2663) e/androidruntime( 4280):        @ android.app.activitythread.handlelaunchactivity(activitythread.java:2679) e/androidruntime( 4280):        @ android.app.activitythread.access$2300(activitythread.java:125) e/androidruntime( 4280):        @ android.app.activitythread$h.handlemessage(activitythread.java:2033) e/androidruntime( 4280):        @ android.os.handler.dispatchmessage(handler.java:99) e/androidruntime( 4280):        @ android.os.looper.loop(looper.java:123) e/androidruntime( 4280):        @ android.app.activitythread.main(activitythread.java:4627) ... 

as says, problem using onclicklistener whereas should using onitemclicklistener.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -