简体   繁体   中英

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.

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. Secondly, use the setSelected() method with the item's position (which you get on the listener).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM