List of usage examples for android.os Bundle putCharSequenceArray
@Override public void putCharSequenceArray(@Nullable String key, @Nullable CharSequence[] value)
From source file:ca.rmen.android.scrumchatter.dialog.DialogFragmentFactory.java
/** * Show a visible dialog fragment with the given title and list of items. If the given activity implements {@link DialogItemListener}, the * actionId, list of items, and item selected by the user, will be provided in the * {@link DialogItemListener#onItemSelected(int, CharSequence[], int)} callback on the activity, when the user selects an item. * @param selectedItem if greater than zero, then the given item at that index will be pre-selected in the list. *//* w w w . j a va2s . co m*/ public static void showChoiceDialog(FragmentActivity activity, String title, CharSequence[] items, int selectedItem, @SuppressWarnings("SameParameterValue") int actionId) { Log.v(TAG, "showChoiceDialog: title = " + title + ", actionId = " + actionId + ", items =" + Arrays.toString(items) + ", selectedItem = " + selectedItem); ChoiceDialogFragment result = new ChoiceDialogFragment(); Bundle arguments = new Bundle(5); arguments.putString(EXTRA_TITLE, title); arguments.putInt(EXTRA_ACTION_ID, actionId); arguments.putCharSequenceArray(EXTRA_CHOICES, items); arguments.putInt(EXTRA_SELECTED_ITEM, selectedItem); result.setArguments(arguments); result.show(activity.getSupportFragmentManager(), ChoiceDialogFragment.class.getSimpleName()); }
From source file:com.syncedsynapse.kore2.ui.GenericSelectDialog.java
/** * Create a new instance of the dialog, providing arguments. * @param listener Listener for selection * @param token Token to be returned on the callback, to differentiate different calls * @param title Title of the dialog/*from w w w. java 2s.c o m*/ * @param items String array of the options to show in the dialog * @param selectedItem Index of the selected item * @return New dialog */ public static GenericSelectDialog newInstance(GenericSelectDialogListener listener, int token, String title, CharSequence[] items, int selectedItem) { GenericSelectDialog dialog = new GenericSelectDialog(); // TODO: This isn't going to survive destroys, but it's the easiast way to communicate dialog.mListener = listener; Bundle args = new Bundle(); args.putInt(TOKEN_KEY, token); args.putString(TITLE_KEY, title); args.putCharSequenceArray(ARRAY_ITEMS, items); args.putInt(SELECTED_ITEM_KEY, selectedItem); dialog.setArguments(args); return dialog; }
From source file:ca.rmen.android.networkmonitor.app.dialog.DialogFragmentFactory.java
/** * Show a visible dialog fragment with the given title and list of items. If the given activity implements {@link DialogItemListener}, the * actionId, list of items, and item selected by the user, will be provided in the * {@link DialogItemListener#onItemSelected(int, CharSequence[], int)} callback on the activity, when the user selects an item. * @param selectedItem if greater than zero, then the given item at that index will be pre-selected in the list. *//*from w w w .j a va 2 s . co m*/ public static void showChoiceDialog(FragmentActivity activity, String title, CharSequence[] items, int selectedItem, int actionId) { Log.v(TAG, "showChoiceDialog: title = " + title + ", actionId = " + actionId + ", items =" + Arrays.toString(items) + ", selectedItem = " + selectedItem); ChoiceDialogFragment result = new ChoiceDialogFragment(); Bundle arguments = new Bundle(5); arguments.putString(EXTRA_TITLE, title); arguments.putInt(EXTRA_ACTION_ID, actionId); arguments.putCharSequenceArray(EXTRA_CHOICES, items); arguments.putInt(EXTRA_SELECTED_ITEM, selectedItem); result.setArguments(arguments); result.show(activity.getSupportFragmentManager(), ChoiceDialogFragment.class.getSimpleName()); }
From source file:com.alicode.android.teraworldevents.TeraTimeActivity.java
@Override public void onSaveInstanceState(Bundle state) { state.putCharSequenceArray(KEY_MODELS, models); state.putInt(KEY_POSITION, getSupportActionBar().getSelectedNavigationIndex()); }
From source file:android.support.v17.preference.LeanbackListPreferenceDialogFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putCharSequence(SAVE_STATE_TITLE, mDialogTitle); outState.putCharSequence(SAVE_STATE_MESSAGE, mDialogMessage); outState.putBoolean(SAVE_STATE_IS_MULTI, mMulti); outState.putCharSequenceArray(SAVE_STATE_ENTRIES, mEntries); outState.putCharSequenceArray(SAVE_STATE_ENTRY_VALUES, mEntryValues); if (mMulti) { outState.putStringArray(SAVE_STATE_INITIAL_SELECTIONS, mInitialSelections.toArray(new String[mInitialSelections.size()])); } else {//from ww w .ja v a 2s . c o m outState.putString(SAVE_STATE_INITIAL_SELECTION, mInitialSelection); } }
From source file:me.xiaopan.android.inject.sample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); listView = new ListView(getBaseContext()); setContentView(listView);//from w w w . j a v a 2s . c o m // SharedPreferences? PreferenceUtils.putBoolean(getBaseContext(), KEY_BOOLEAN, true); PreferenceUtils.putFloat(getBaseContext(), KEY_FLOAT, 10000f); PreferenceUtils.putInt(getBaseContext(), KEY_INT, 2000); PreferenceUtils.putLong(getBaseContext(), KEY_LONG, 50000); PreferenceUtils.putString(getBaseContext(), KEY_STRING, "Preference String"); Set<String> stringSet = new HashSet<String>(); stringSet.add("String Set 1"); stringSet.add("String Set 2"); stringSet.add("String Set 3"); stringSet.add("String Set 4"); PreferenceUtils.putStringSet(getBaseContext(), KEY_STRING_SET, stringSet); MyBean bean2 = new MyBean(); bean2.setEmail("sky@xiaopan.me2"); bean2.setName("?2"); bean2.setSex("2"); PreferenceUtils.putObject(getBaseContext(), KEY_JSON, bean2); PreferenceUtils.putString(getBaseContext(), KEY_ENUM, Sex.WOMAN.name()); // ?? String[] items = new String[] { "", "?", "FragmentDialog", "InjectAdapter", "InjectExpandableListAdapter" }; listView.setAdapter(new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1, android.R.id.text1, items)); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position <= 2) { Bundle bundle = new Bundle(); bundle.putBoolean(MainActivity.PARAM_BOOLEAN, true); bundle.putBooleanArray(MainActivity.PARAM_BOOLEAN_ARRAY, new boolean[] { true, false, true }); bundle.putByte(MainActivity.PARAM_BYTE, (byte) 110); bundle.putByteArray(MainActivity.PARAM_BYTE_ARRAY, new byte[] { 111, 112, 113 }); bundle.putChar(MainActivity.PARAM_CHAR, 'R'); bundle.putCharArray(MainActivity.PARAM_CHAR_ARRAY, new char[] { 'c', 'h', 'a', 'r' }); bundle.putCharSequence(MainActivity.PARAM_CHAR_SEQUENCE, "CharSequence"); bundle.putCharSequenceArray(MainActivity.PARAM_CHAR_SEQUENCE_ARRAY, new CharSequence[] { "Char", " ", "Sequence" }); bundle.putDouble(MainActivity.PARAM_DOUBLE, 12.00d); bundle.putDoubleArray(MainActivity.PARAM_DOUBLE_ARRAY, new double[] { 12.01d, 12.02d, 12.03d }); bundle.putFloat(MainActivity.PARAM_FLOAT, 13.00f); bundle.putFloatArray(MainActivity.PARAM_FLOAT_ARRAY, new float[] { 13.01f, 13.02f, 13.03f }); bundle.putInt(MainActivity.PARAM_INT, 120); bundle.putIntArray(MainActivity.PARAM_INT_ARRAY, new int[] { 121, 122, 123, }); bundle.putLong(MainActivity.PARAM_LONG, 12345); bundle.putLongArray(MainActivity.PARAM_LONG_ARRAY, new long[] { 12346, 12347, 12348 }); bundle.putShort(MainActivity.PARAM_SHORT, (short) 2); bundle.putShortArray(MainActivity.PARAM_SHORT_ARRAY, new short[] { 3, 4, 5 }); bundle.putString(MainActivity.PARAM_STRING, "String"); bundle.putStringArray(MainActivity.PARAM_STRING_ARRAY, new String[] { "String1", "String2", "String3" }); // ??JSONBundle MyBean bean = new MyBean(); bean.setEmail("sky@xiaopan.me"); bean.setName("?"); bean.setSex(""); bundle.putString(PARAM_STRING_JSON, new Gson().toJson(bean)); bundle.putString(MainActivity.PARAM_STRING_ENUM, Sex.WOMAN.name()); // ArrayList<String> stringList = new ArrayList<String>(); stringList.add("ArrayList String 1"); stringList.add("ArrayList String 2"); stringList.add("ArrayList String 3"); bundle.putStringArrayList(MainActivity.PARAM_STRING_ARRAY_LIST, stringList); switch (position) { case 0: Second.SECOND_CHRONOGRAPH.lap(); Intent intent = new Intent(getBaseContext(), InjectTestActivity.class); intent.putExtras(bundle); startActivity(intent); break; case 1: Second.SECOND_CHRONOGRAPH.lap(); Intent intent2 = new Intent(getBaseContext(), NormalActivity.class); intent2.putExtras(bundle); startActivity(intent2); break; case 2: Second.SECOND_CHRONOGRAPH.lap(); new TestDialogFragment().show(getSupportFragmentManager(), ""); break; } } else { Class<?> targetClass = null; if (position == 3) { targetClass = InjectAdapterActivity.class; } else if (position == 4) { targetClass = InjectExpandableListAdapterActivity.class; } if (targetClass != null) { startActivity(new Intent(getBaseContext(), targetClass)); } } } }); }
From source file:com.facebook.react.modules.dialog.DialogModule.java
@ReactMethod public void showAlert(ReadableMap options, Callback errorCallback, Callback actionCallback) { FragmentManagerHelper fragmentManagerHelper = getFragmentManagerHelper(); if (fragmentManagerHelper == null) { errorCallback.invoke("Tried to show an alert while not attached to an Activity"); return;//from ww w . ja v a 2 s . com } final Bundle args = new Bundle(); if (options.hasKey(KEY_TITLE)) { args.putString(AlertFragment.ARG_TITLE, options.getString(KEY_TITLE)); } if (options.hasKey(KEY_MESSAGE)) { args.putString(AlertFragment.ARG_MESSAGE, options.getString(KEY_MESSAGE)); } if (options.hasKey(KEY_BUTTON_POSITIVE)) { args.putString(AlertFragment.ARG_BUTTON_POSITIVE, options.getString(KEY_BUTTON_POSITIVE)); } if (options.hasKey(KEY_BUTTON_NEGATIVE)) { args.putString(AlertFragment.ARG_BUTTON_NEGATIVE, options.getString(KEY_BUTTON_NEGATIVE)); } if (options.hasKey(KEY_BUTTON_NEUTRAL)) { args.putString(AlertFragment.ARG_BUTTON_NEUTRAL, options.getString(KEY_BUTTON_NEUTRAL)); } if (options.hasKey(KEY_ITEMS)) { ReadableArray items = options.getArray(KEY_ITEMS); CharSequence[] itemsArray = new CharSequence[items.size()]; for (int i = 0; i < items.size(); i++) { itemsArray[i] = items.getString(i); } args.putCharSequenceArray(AlertFragment.ARG_ITEMS, itemsArray); } fragmentManagerHelper.showNewAlert(mIsInForeground, args, actionCallback); }