我试图阻止 ListView 滚动。 我在其他主题(例如 How to get a non scrollable ListView?)中看到使用线性布局来代替。 但是,这在我的应用程序中是不可能的,我的 ListView 是可编程填充的,所以我需要这个组件。 感谢回复
编辑:在不更改我的整个代码的情况下,最简单的方法似乎是将 scroolview 中的其他项目添加到 ListView 中作为标题,因此我不再需要 scroolview。
但是,listview 适配器似乎无法正常工作。我已经看到我必须使用 wrappedListadapter,但我不知道该怎么做。
这是我用来设置适配器的代码:
SimpleAdapter mSchedule = new SimpleAdapter(this.getBaseContext(), listItem, R.layout.consultafficheitem,
new String[] {"description", "ingredient"}, new int[] {R.id.consultlistdescription, R.id.consultlistingredients});
scroll = (RelativeLayout) findViewById(R.id.consultscrollrelativelayout);
liste.addHeaderView(scroll);
liste.setAdapter(mSchedule);
最佳答案
我会使用 View.OnTouchListener
并简单地使用类似的东西
if(event.getAction == MotionEvent.ACTION_MOVE) {
// Ignore move events
return true;
} else {
return false;
}
关于android使 ListView 不可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16145156/