English 中文(简体)
一、执行《公约》的情况 没有工作
原标题:ListView onItemClick which implements Activity is not working

我有一份清单,介绍活动情况,并使用定制改编器,因为我想在清单中一行和案文。

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);

然后,我利用PetOnItemClickListener使清单调查被点击但失败。

MenuList.setOnItemClickListener(new ListView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
            Intent myIntent = new Intent(Menu.this, Revision.class);    
            Menu.this.startActivity(myIntent);
            }
    }); 

Here is the logcat:

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)

AIM: clickable listview which would bring up other activities. Thanks guys

最佳回答

看来,你的问题实际上可能是订正的。 班级。 如果看不见该法典,我可以肯定地说,但记录部分指出:

 java.lang.ClassCastException: android.widget.LinearLayout
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签