本文整理了Java中android.widget.ListView.onSaveInstanceState()
方法的一些代码示例,展示了ListView.onSaveInstanceState()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListView.onSaveInstanceState()
方法的具体详情如下:
包路径:android.widget.ListView
类名称:ListView
方法名:onSaveInstanceState
暂无
代码示例来源:origin: k9mail/k-9
@Override
public void onDestroyView() {
savedListState = listView.onSaveInstanceState();
super.onDestroyView();
}
代码示例来源:origin: k9mail/k-9
private void saveListState(Bundle outState) {
if (savedListState != null) {
// The previously saved state was never restored, so just use that.
outState.putParcelable(STATE_MESSAGE_LIST, savedListState);
} else if (listView != null) {
outState.putParcelable(STATE_MESSAGE_LIST, listView.onSaveInstanceState());
}
}
代码示例来源:origin: ksoichiro/Android-ObservableScrollView
@Override
public Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
SavedState ss = new SavedState(superState);
ss.prevFirstVisiblePosition = mPrevFirstVisiblePosition;
ss.prevFirstVisibleChildHeight = mPrevFirstVisibleChildHeight;
ss.prevScrolledChildrenHeight = mPrevScrolledChildrenHeight;
ss.prevScrollY = mPrevScrollY;
ss.scrollY = mScrollY;
ss.childrenHeights = mChildrenHeights;
return ss;
}
代码示例来源:origin: com.albedinsky.android/ui
/**
*/
@Override
public Parcelable onSaveInstanceState() {
final Adapter adapter = getAdapter();
if (adapter != null) {
final Parcelable adapterState = saveAdapterState(adapter);
if (adapterState != null) {
final SavedState savedState = new SavedState(super.onSaveInstanceState());
savedState.adapterState = adapterState;
return savedState;
}
}
return super.onSaveInstanceState();
}
代码示例来源:origin: geniusgithub/AndroidDialer
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(KEY_SECTION_HEADER_DISPLAY_ENABLED, mSectionHeaderDisplayEnabled);
outState.putBoolean(KEY_PHOTO_LOADER_ENABLED, mPhotoLoaderEnabled);
outState.putBoolean(KEY_QUICK_CONTACT_ENABLED, mQuickContactEnabled);
outState.putBoolean(KEY_ADJUST_SELECTION_BOUNDS_ENABLED, mAdjustSelectionBoundsEnabled);
outState.putBoolean(KEY_INCLUDE_PROFILE, mIncludeProfile);
outState.putBoolean(KEY_SEARCH_MODE, mSearchMode);
outState.putBoolean(KEY_VISIBLE_SCROLLBAR_ENABLED, mVisibleScrollbarEnabled);
outState.putInt(KEY_SCROLLBAR_POSITION, mVerticalScrollbarPosition);
outState.putInt(KEY_DIRECTORY_SEARCH_MODE, mDirectorySearchMode);
outState.putBoolean(KEY_SELECTION_VISIBLE, mSelectionVisible);
outState.putBoolean(KEY_LEGACY_COMPATIBILITY, mLegacyCompatibility);
outState.putString(KEY_QUERY_STRING, mQueryString);
outState.putInt(KEY_DIRECTORY_RESULT_LIMIT, mDirectoryResultLimit);
outState.putBoolean(KEY_DARK_THEME, mDarkTheme);
if (mListView != null) {
outState.putParcelable(KEY_LIST_STATE, mListView.onSaveInstanceState());
}
}
代码示例来源:origin: com.albedinsky.android/ui-widget-collection
/**
*/
@Override
public Parcelable onSaveInstanceState() {
final Adapter adapter = getAdapter();
if (adapter != null) {
final Parcelable adapterState = saveAdapterState(adapter);
if (adapterState != null) {
final SavedState savedState = new SavedState(super.onSaveInstanceState());
savedState.adapterState = adapterState;
return savedState;
}
}
return super.onSaveInstanceState();
}
代码示例来源:origin: stackoverflow.com
public class MainActivity extends Activity {
private ListView listView;
private ItemArrayAdapter itemArrayAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = (ListView) findViewById(R.id.listView);
itemArrayAdapter = new ItemArrayAdapter(getApplicationContext(), R.layout.item_layout);
Parcelable state = listView.onSaveInstanceState();
listView.setAdapter(itemArrayAdapter);
listView.onRestoreInstanceState(state);
InputStream inputStream = getResources().openRawResource(R.raw.stats);
CSVFile csvFile = new CSVFile(inputStream);
List scoreList = csvFile.read();
for(String[] scoreData:scoreList ) {
itemArrayAdapter.add(scoreData);
}
}
}
代码示例来源:origin: tomahawk-player/tomahawk-android
/**
* @return the current scrolling position of the list- or gridView
*/
private Parcelable getListState() {
if (getListView() != null) {
return getListView().getWrappedList().onSaveInstanceState();
}
return null;
}
代码示例来源:origin: stackoverflow.com
Parcelable state = lv.onSaveInstanceState();
int index = lv.getLastVisiblePosition();
lv.setAdapter(adapter);
代码示例来源:origin: stackoverflow.com
Parcelable state = lv.onSaveInstanceState();
代码示例来源:origin: dsolonenko/financisto
public void recreateCursor() {
Log.i("AbstractListActivity", "Recreating cursor");
Parcelable state = getListView().onSaveInstanceState();
try {
if (cursor != null) {
stopManagingCursor(cursor);
cursor.close();
}
cursor = createCursor();
if (cursor != null) {
startManagingCursor(cursor);
recreateAdapter();
}
} finally {
getListView().onRestoreInstanceState(state);
}
}
代码示例来源:origin: tomahawk-player/tomahawk-android
listView.setOnHeaderClickListener(this);
if (mDrillDownCount == mLastDrillDownCount) {
Parcelable listState = listView.getWrappedList().onSaveInstanceState();
listView.setAdapter(mAdapter);
listView.getWrappedList().onRestoreInstanceState(listState);
内容来源于网络,如有侵权,请联系作者删除!