List of usage examples for android.preference PreferenceScreen getDialog
public Dialog getDialog()
From source file:de.tum.in.tumcampus.fragments.SettingsFragment.java
/** * Sets up the action bar for an {@link PreferenceScreen} *///from w w w. ja v a 2 s . c om @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void initializeActionBar(PreferenceScreen preferenceScreen) { final Dialog dialog = preferenceScreen.getDialog(); //Check if dialog is open and if we are on a supported android version if (dialog != null && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { //Setup a dialog back button pressed listener dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mContext.finish(); } }); } }
From source file:com.github.howeyc.slideshow.activities.SettingsActivity.java
/************************************************************************************ * needed because else the nested preference screen don't have a actionbar/toolbar * * see the fix and the given problem here: http://stackoverflow.com/a/27455363 * ************************************************************************************/ public void setUpNestedScreen(PreferenceScreen preferenceScreen) { final Dialog dialog = preferenceScreen.getDialog(); //ViewGroup list; Toolbar bar;//w w w .j a v a2 s.c o m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { //list = (ViewGroup) dialog.findViewById(android.R.id.list); LinearLayout root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent(); bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); root.addView(bar, 0); // insert at top } else { ViewGroup root = (ViewGroup) dialog.findViewById(android.R.id.content); ListView content = (ListView) root.getChildAt(0); //list = content; root.removeAllViews(); bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); int height; TypedValue tv = new TypedValue(); if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) { height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); } else { height = bar.getHeight(); } content.setPadding(0, height, 0, 0); root.addView(content); root.addView(bar); } //list.addView(detailsPrefScreenToAdd.getStatusViewGroup(), 1); //TODO bar.setTitle(preferenceScreen.getTitle()); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogI) { if (AppData.getLoginSuccessful()) { dialogI.dismiss(); } else { showNotConnectedDialog(dialog); } } }); bar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (AppData.getLoginSuccessful()) { dialog.dismiss(); } else { showNotConnectedDialog(dialog); } } }); }
From source file:com.xperia64.timidityae.SettingsActivity.java
public void setUpNestedScreen(PreferenceScreen preferenceScreen) { final Dialog dialog = preferenceScreen.getDialog(); Toolbar bar;/*from w w w . j ava2 s .c om*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LinearLayout root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent(); bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); bar.setElevation(abElevation); root.addView(bar, 0); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { LinearLayout root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent(); bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); root.addView(bar, 0); // insert at top } else { ViewGroup root = (ViewGroup) dialog.findViewById(android.R.id.content); ListView content = (ListView) root.getChildAt(0); root.removeAllViews(); bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); int height; TypedValue tv = new TypedValue(); if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) { height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); } else { height = bar.getHeight(); } content.setPadding(0, height, 0, 0); root.addView(content); root.addView(bar); } bar.setTitle(preferenceScreen.getTitle()); bar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); }