List of usage examples for android.widget ListView onSaveInstanceState
@Override
public Parcelable onSaveInstanceState()
From source file:de.measite.contactmerger.MergeActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); ListView list = (ListView) findViewById(R.id.contact_merge_list); outState.putParcelable("MERGELIST", list.onSaveInstanceState()); }
From source file:com.murati.oszk.audiobook.ui.MediaBrowserFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LogHelper.d(TAG, "fragment.onCreateView"); //TODO: rethink mMediaId in instance context final String mediaId = getMediaId(); // Update Favoritebutton on backstack navigate try {/* w ww. j a v a2s .c o m*/ ((MusicPlayerActivity) this.getActivity()).updateBookButtons(mediaId); } catch (Exception ex) { Log.e(TAG, ex.getMessage()); } View rootView = inflater.inflate(R.layout.fragment_list, container, false); mErrorView = rootView.findViewById(R.id.playback_error); mErrorMessage = (TextView) mErrorView.findViewById(R.id.error_message); mBrowserAdapter = new BrowseAdapter(getActivity()); final ListView listView = (ListView) rootView.findViewById(R.id.list_view); listView.setAdapter(mBrowserAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { checkForUserVisibleErrors(false); if (mediaId != null) { //TODO: listview restore position Parcelable state = listView.onSaveInstanceState(); if (listState.containsKey(mediaId)) { ((ConcurrentHashMap) listState).remove(mediaId); } ((ConcurrentHashMap) listState).put(mediaId, state); } MediaBrowserCompat.MediaItem item = mBrowserAdapter.getItem(position); mMediaFragmentListener.onMediaItemSelected(item); } }); // Restore listViewState if we have previous if (mediaId != null && listState.containsKey(mediaId)) { listView.onRestoreInstanceState(listState.get(mediaId)); } return rootView; }
From source file:org.solovyev.android.messenger.BaseListFragment.java
@Nullable private Parcelable createListViewState() { final ListView listView = getListViewById(); if (listView != null) { return listView.onSaveInstanceState(); }// w w w . ja v a2 s. com return null; }
From source file:com.juick.android.MessagesFragment.java
public Object saveState() { try {/*from w w w . ja va 2 s . c om*/ ListView listView = getListView(); RetainedData rd = new RetainedData(new ArrayList<JuickMessage>(), listView.onSaveInstanceState()); int count = listAdapter.getCount(); for (int i = 0; i < count; i++) { rd.messages.add(listAdapter.getItem(i)); } return rd; } catch (IllegalStateException e) { // view not yet created return null; } }