java - 安卓 如何实现RecyclerView嵌套listview 实现类似淘宝购物车这种的数据显示
PHP中文网
PHP中文网 2017-04-18 10:46:03
0
3
948
PHP中文网
PHP中文网

认证0级讲师

reply all(3)
迷茫

Why does it have to be nested? You can have a listview on the left and a listview or fragment on the right. When you click on the item of the listview, wouldn’t it be nice to change the data on the right

伊谢尔伦

The layout of item can be a TextView and a LinearLayout, where LinearLayout can addView.
The pseudo code is as follows, first encapsulate the data

class CourseList{

String name;
List<Course> courses;

}

When binding data in Adapter,

TextView.setText(name)

for(i=0;i<courses.size();i++){

  TextView tv =new TextView();
  tv.setText(courses.get(i).name);
  LinearLayout.add(tv);

}

Another idea is that the layout of the item is TextView and RecycleView, but considering that when the number of specific courses exceeds the screen height, there will be a sliding conflict with the parent ListView, which is very troublesome to solve.

阿神

The solution mentioned above is a solution, but actually nesting is not that troublesome. You rewrite the onDispatchTouchEvent event of the child view and make a sliding gesture judgment. If it is sliding, give up processing the entire event sequence, or rewrite the parent view. OnDispatchTouchEvent is no longer distributed when it slides. The principle is the same.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template