[英]Bring a selected ListView Item to the top
I have listviews inside a pager adapter, and I'm trying to make it so when I click on an item inside my listview, it will scroll that item to the top. 我在寻呼机适配器中有列表视图,并且我试图这样做,因此当我单击列表视图中的项目时,它将把该项目滚动到顶部。 I have an onclicklistener to the item, but I'm not sure how exactly to implement the scrolling given what I have.
我对该项目有一个onclicklistener,但是我不确定在给定的条件下如何完全实现滚动。
public Object instantiateItem(ViewGroup container, int position) {
List<App> app = this.apps.get(position);
ListView list = new ListView(this.activity);
list.setAdapter(adapter);
container.addView(list);
return list;
}
First, use ListView's onItemClickListener. 首先,使用ListView的onItemClickListener。 Secondly, use the setSelected() method with the item's position (which you get on the listener).
其次,将setSelected()方法与项目的位置(在侦听器上获得)一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.