这是我的整个活动代码,如果是nessery我也可以发布我的xml。
public class Main_Activityextends AppCompatActivity {
private RecyclerView recyclerview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
recyclerview = (RecyclerView) findViewById(R.id.recyclerview);
recyclerview.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
List<ExpandableListViewAdapter.Item> data = new ArrayList<>();
data.add(new ExpandableListViewAdapter.Item(ExpandableListViewAdapter.HEADER, "Terms of usage"));
data.add(new ExpandableListViewAdapter.Item(ExpandableListViewAdapter.CHILD, "never eat"));
data.add(new ExpandableListViewAdapter.Item(ExpandableListViewAdapter.CHILD, "bluhhhhh"));
recyclerview.setAdapter(new ExpandableListViewAdapter(data));
recyclerview.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
return true;
}
});
代码在没有clickListener
的情况下运行良好,但是我希望在点击数组的某个子项时发生操作,但是现在虽然Cannot resolve method setOnChildClickListener(anonymous android.widget.ExpendableListView.OnChildClickListener)
是recycleView
Adapter
,任何帮助将不胜感激
答案 0 :(得分:2)
简单地说,fflush(0)
不支持fork
,因为它不是一个替代RecyclerView
的直接版本。
要了解原因,请查看this stackoverflow answer
您应该在OnChildClickListener
类中实现ListView
,如下所示:
View.OnClickListener