我從Sq-lite db.
填充列表視圖現在我的問題是,當我點擊列表視圖項目轉到下一頁,然後回到列表視圖,我想列表滾動到相同的點這是以前的任何想法如何做到這一點。如何保持ListView的位置,而回到以前的ListView?
這是我在
的onCreate(list-view
法)
private void populateList() {
descArray.clear();
List<All_Post> allDesc = dbhelper.getAllDescriptions();
for (All_Post all_Post : allDesc)
{
String strInspectorname = all_Post.getStringInspectorname();
Log.e("strInspectorname "," = " + strInspectorname);
descArray.add(all_Post);
}
if (adapter == null)
{
adapter = new AllPostAdapter(this, R.layout.allpostlist, descArray);
listView.setAdapter(adapter);
}
else if (adapter != null) {
adapter.notifyDataSetChanged();
adapter = new AllPostAdapter(this, R.layout.allpostlist, descArray);
listView.setAdapter(adapter);
}
}
我試過這個鏈接Maintain/Save/Restore scroll position when returning to a ListView,ListView控件去alwyas最後位置。
我使用你的代碼行,但listview總是滾動的位置是0 –
你可以嘗試從http://stackoverflow.com/questions/3014089解決方案/維持保存-恢復渦卷器位置時,返回到一個-列表視圖?RQ = 1 – Neo