【发布时间】:2015-03-11 20:03:54
【问题描述】:
我正在创建一个应用程序,其中有一个包含列表视图的Fragment,这个ListView 托管在主活动中。
列表中的每个项目都包含 10-20 个按钮。如何将点击监听器附加到它们并在点击时执行操作,IE 更新屏幕上的信息?
编辑:更多信息
listFragment 内部:
public void myButtonHandler(View view){
//Handles method actions
}
主要活动内部:
public void myButtonHandler(View v){listFragment.myButtonHandler(v);
}
错误:
05-09 11:15:27.900 7122-7122/project.rapid.proto E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: project.rapid.proto, PID: 7122
java.lang.IllegalStateException: Could not find a method myButtonHandler(View) in the activity class android.app.Application for onClick handler on view class android.widget.ImageButton with id 'required2'
按钮单击对片段中包含的信息执行操作,这就是我尝试调用的原因。
【问题讨论】:
-
请阅读How to Ask。你试过什么?你做了什么研究?你有错误吗?你能给我们看一些代码吗?
标签: android android-fragments android-listview android-adapter