這裏是我的整個活動代碼,如果需要我也可以發佈我的xml。無法解析方法setOnChildClickListener
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
,任何幫助將不勝感激
嘗試添加'機器人:descendantFocusability = 「blocksDescendants」'上你的子視圖 –
仍然是相同的結果 –
你有烤麪包什麼的可以知道它不是火嗎? –