Variable groupPosition is accessed from within inner class,needs to be declared final.
3条回答 默认 最新
- danielinbiti 2015-05-27 08:35关注
继承一下 class MyClickListener implements View.OnClickListener { private int groupPosition; private int childPosition; public MyClickListener(int groupPosition,int childPosition){ this.groupPosition = groupPosition; this.childPosition = childPosition; } public void onClick(View v) { System.out.println(this.groupPosition); System.out.println(this.childPosition); } } 然后 childImage.setOnClickListener(new MyClickListener(groupPosition,childPosition));
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
- ¥15 android报错 brut.common.BrutException: could not exec (exit code = 1)
- ¥15 nginx反向代理获取ip,java获取真实ip
- ¥15 eda:门禁系统设计
- ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
- ¥15 376.1电表主站通信协议下发指令全被否认问题
- ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
- ¥15 复杂网络,变滞后传递熵,FDA
- ¥20 csv格式数据集预处理及模型选择
- ¥15 部分网页页面无法显示!