Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个简单的自定义适配器。我需要在不同的时间将起始位置设置为不同的位置。使用标准列表适配器时,我可以简单地使用 myCursor.moveToPosition(i)。使用 getview 的自定义适配器不能以这种方式工作。谁能告诉我如何将当前列表移动到我想要的位置?
如果您的 ListView 可用,请使用:getListView().setSelection( i );
getListView().setSelection( i );
(或 myListView.setSelection(i);)
myListView.setSelection(i);
您还可以使用以下方法获取当前位置(也许返回到 onResume):
int myPosition = getListView().getFirstVisiblePosition();