public class LocalePickerWithRegion extends ListFragment implements SearchView.OnQueryTextListener
It shows suggestions at the top, then the rest of the locales. Allows the user to search for locales using both their native name and their name in the default locale.
Modifier and Type | Class and Description |
---|---|
static interface |
LocalePickerWithRegion.LocaleSelectedListener
Other classes can register to be notified when a locale was selected.
|
Fragment.InstantiationException, Fragment.SavedState
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
LocalePickerWithRegion() |
Modifier and Type | Method and Description |
---|---|
static LocalePickerWithRegion |
createLanguagePicker(Context context,
LocalePickerWithRegion.LocaleSelectedListener listener,
boolean translatedOnly) |
void |
onCreate(Bundle savedInstanceState)
Called to do initial creation of a fragment.
|
void |
onCreateOptionsMenu(Menu menu,
MenuInflater inflater)
Initialize the contents of the Activity's standard options menu.
|
void |
onListItemClick(ListView l,
View v,
int position,
long id)
This method will be called when an item in the list is selected.
|
boolean |
onOptionsItemSelected(MenuItem menuItem)
This hook is called whenever an item in your options menu is selected.
|
void |
onPause()
Called when the Fragment is no longer resumed.
|
boolean |
onQueryTextChange(String newText)
Called when the query text is changed by the user.
|
boolean |
onQueryTextSubmit(String query)
Called when the user submits the query.
|
void |
onResume()
Called when the fragment is visible to the user and actively running.
|
getListAdapter, getListView, getSelectedItemId, getSelectedItemPosition, onCreateView, onDestroyView, onViewCreated, setEmptyText, setListAdapter, setListShown, setListShownNoAnimation, setSelection
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isRemoving, isResumed, isVisible, onActivityCreated, onActivityResult, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimator, onCreateContextMenu, onDestroy, onDestroyOptionsMenu, onDetach, onHiddenChanged, onInflate, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsMenuClosed, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onSaveInstanceState, onStart, onStop, onTrimMemory, onViewStateRestored, registerForContextMenu, requestPermissions, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterSharedElementTransitionCallback, setEnterTransition, setExitSharedElementCallback, setExitSharedElementTransitionCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, toString, unregisterForContextMenu
public static LocalePickerWithRegion createLanguagePicker(Context context, LocalePickerWithRegion.LocaleSelectedListener listener, boolean translatedOnly)
public void onCreate(Bundle savedInstanceState)
Fragment
Fragment.onAttach(Activity)
and before
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
, but is not called if the fragment
instance is retained across Activity re-creation (see Fragment.setRetainInstance(boolean)
).
Note that this can be called while the fragment's activity is
still in the process of being created. As such, you can not rely
on things like the activity's content view hierarchy being initialized
at this point. If you want to do work once the activity itself is
created, see Fragment.onActivityCreated(Bundle)
.
If your app's targetSdkVersion
is Build.VERSION_CODES.M
or lower, child fragments being restored from the savedInstanceState are restored after
onCreate
returns. When targeting Build.VERSION_CODES.N
or
above and running on an N or newer platform version
they are restored by Fragment.onCreate
.
public boolean onOptionsItemSelected(MenuItem menuItem)
Fragment
Derived classes should call through to the base class for it to perform the default menu handling.
onOptionsItemSelected
in class Fragment
menuItem
- The menu item that was selected.Fragment.onCreateOptionsMenu(android.view.Menu, android.view.MenuInflater)
public void onResume()
Fragment
Activity.onResume
of the containing
Activity's lifecycle.public void onPause()
Fragment
Activity.onPause
of the containing
Activity's lifecycle.public void onListItemClick(ListView l, View v, int position, long id)
ListFragment
onListItemClick
in class ListFragment
l
- The ListView where the click happenedv
- The view that was clicked within the ListViewposition
- The position of the view in the listid
- The row id of the item that was clickedpublic void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
Fragment
Fragment.setHasOptionsMenu(boolean)
. See
Activity.onCreateOptionsMenu
for more information.onCreateOptionsMenu
in class Fragment
menu
- The options menu in which you place your items.Fragment.setHasOptionsMenu(boolean)
,
Fragment.onPrepareOptionsMenu(android.view.Menu)
,
Fragment.onOptionsItemSelected(android.view.MenuItem)
public boolean onQueryTextSubmit(String query)
SearchView.OnQueryTextListener
onQueryTextSubmit
in interface SearchView.OnQueryTextListener
query
- the query text that is to be submittedpublic boolean onQueryTextChange(String newText)
SearchView.OnQueryTextListener
onQueryTextChange
in interface SearchView.OnQueryTextListener
newText
- the new content of the query text field.