Note that there are some explanatory texts on larger screens.

plurals
  1. POListView onItemClick which implements Activity is not working
    primarykey
    data
    text
    <p>I have a listview extends Activity and use custom adapter because I want icon and text on the listview.</p> <pre><code>String[] options = res.getStringArray(R.array.menu_title); TypedArray icons = res.obtainTypedArray(R.array.menu_icon); ImageAndTextAdapter iadapter = new ImageAndTextAdapter(ctx, R.layout.row, options, icons); MenuList.setAdapter(iadapter); </code></pre> <p>Then I use the setOnItemClickListener to make the listview clickable but fail.</p> <pre><code>MenuList.setOnItemClickListener(new ListView.OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; arg0, View v, int position, long id) { Intent myIntent = new Intent(Menu.this, Revision.class); Menu.this.startActivity(myIntent); } }); </code></pre> <p>Here is the logcat:</p> <blockquote> <p>11-22 16:55:17.419: E/AndroidRuntime(2056): FATAL EXCEPTION: main 11-22 16:55:17.419: E/AndroidRuntime(2056): java.lang.ClassCastException: android.widget.LinearLayout 11-22 16:55:17.419: E/AndroidRuntime(2056): at cs.ucl.cw.Menu$1.onItemClick(Menu.java:54) 11-22 16:55:17.419: E/AndroidRuntime(2056): at android.widget.AdapterView.performItemClick(AdapterView.java:284) 11-22 16:55:17.419: E/AndroidRuntime(2056): at android.widget.ListView.performItemClick(ListView.java:3513) 11-22 16:55:17.419: E/AndroidRuntime(2056): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1849) 11-22 16:55:17.419: E/AndroidRuntime(2056): at android.os.Handler.handleCallback(Handler.java:587) 11-22 16:55:17.419: E/AndroidRuntime(2056): at android.os.Handler.dispatchMessage(Handler.java:92) 11-22 16:55:17.419: E/AndroidRuntime(2056): at android.os.Looper.loop(Looper.java:130) 11-22 16:55:17.419: E/AndroidRuntime(2056): at android.app.ActivityThread.main(ActivityThread.java:3835) 11-22 16:55:17.419: E/AndroidRuntime(2056): at java.lang.reflect.Method.invokeNative(Native Method) 11-22 16:55:17.419: E/AndroidRuntime(2056): at java.lang.reflect.Method.invoke(Method.java:507) 11-22 16:55:17.419: E/AndroidRuntime(2056): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 11-22 16:55:17.419: E/AndroidRuntime(2056): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 11-22 16:55:17.419: E/AndroidRuntime(2056): at dalvik.system.NativeStart.main(Native Method)</p> </blockquote> <p>AIM: clickable listview which would bring up other activities. Thanks guys</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload