实际上我需要的是当用户水平滚动列表项时,列表视图中的所有项目都应该滚动。
答案 0 :(得分:0)
使用 Appcompat 库中的 RecyclerView 。你可以找到水平滚动
RecyclerView mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
mCrimes = CrimeLab.get(getActivity()).getCrimes();
mRecyclerView.setAdapter(new CrimeAdapter());
答案 1 :(得分:0)
是的,你可以那样做
转到下面的链接我猜你需要的是那里!!
https://guides.codepath.com/android/Implementing-a-Horizontal-ListView-Guide
快乐的编码!!
答案 2 :(得分:0)
你可以这样做,我的测试就是工作:
//first: regist Listener
hScrollView.setOnTouchListener(new scroll(hScrollView));
//second: loop ListView child, and setScrollX for each HorizontalScrollView
class scroll implements OnTouchListener{
HorizontalScrollView hScrollView;
scroll(HorizontalScrollView view){
this.hScrollView = view;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_MOVE){
Log.i(getClass().getSimpleName(), "Scroll X = "+ hScrollView.getScrollX());
int x = hScrollView.getScrollX();
for(int i=0; i<managerList.getChildCount(); i++){
View view = managerList.getChildAt(i);
HorizontalScrollView scrollView = (HorizontalScrollView) view.findViewById(R.id.list_scroll);
scrollView.setScrollX(x);
}
}
return false;
}
}
希望可以帮到你。