开发者

Android how can you implement moveToPosition with a Custom Adapter

开发者 https://www.devze.com 2022-12-31 03:54 出处:网络
I have a simple custom adapter.I need to set thestarting position to different positions at different times.When using a standard listadapter, I can simply u开发者_C百科se myCursor.moveToPosition( i )

I have a simple custom adapter. I need to set the starting position to different positions at different times. When using a standard listadapter, I can simply u开发者_C百科se myCursor.moveToPosition( i ). A custom adapter using getview does not work that way. Can anyone tell me how to move the current list to the position I want?


If your ListView is available, use: getListView().setSelection( i );

(or myListView.setSelection(i); )





You can also get the current position (to return to in onResume, perhaps) by using:

int myPosition = getListView().getFirstVisiblePosition();

0

精彩评论

暂无评论...
验证码 换一张
取 消