今天想到一个问题如果我选了listView中的一个item 的位置然后启动另一个activity回来的时候在返回那个位置
@Override
protected void onPause()
{
// Save scroll position
SharedPreferences preferences = context.getSharedPreferences("SCROLL", 0);
SharedPreferences.Editor editor = preferences.edit();
int scroll = mListView.getScrollY();
editor.put("ScrollValue", scroll);
editor.commit();
}
@Override
protected void onResume()
{
// Get the scroll position
SharedPreferences preferences = context.getSharedPreferences("SCROLL", 0);
int scroll = preferences.getInt("ScrollView", 0);
mListView.scrollTo(0, scroll);
}
竟然忘记使用SharedPreference了