List of usage examples for android.app AlertDialog getListView
public ListView getListView()
From source file:org.peterbaldwin.vlcremote.fragment.HotkeyDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Context context = getActivity(); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setItems(R.array.hotkey_labels, null); builder.setNeutralButton(R.string.close, null); AlertDialog dialog = builder.create(); // Handle ListView item clicks directly so that dialog is not dismissed dialog.getListView().setOnItemClickListener(this); return dialog; }
From source file:org.gateshipone.odyssey.dialogs.ChooseBookmarkDialog.java
/** * Create the dialog to choose to override an existing bookmark or to create a new bookmark. */// w w w .ja v a 2 s . co m @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); mBookmarksAdapter = new BookmarksAdapter(getActivity()); builder.setTitle(R.string.dialog_choose_bookmark) .setAdapter(mBookmarksAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { // open save dialog to create a new bookmark SaveDialog saveDialog = SaveDialog.newInstance(SaveDialog.OBJECTTYPE.BOOKMARK); saveDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "SaveDialog"); } else { // override existing bookmark BookmarkModel bookmark = (BookmarkModel) mBookmarksAdapter.getItem(which); String objectTitle = bookmark.getTitle(); mSaveCallback.onSaveObject(objectTitle, SaveDialog.OBJECTTYPE.BOOKMARK); } } }).setNegativeButton(R.string.dialog_action_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog dont save object getDialog().cancel(); } }); // Prepare loader ( start new one or reuse old ) getLoaderManager().initLoader(0, getArguments(), this); // set divider AlertDialog dlg = builder.create(); dlg.getListView().setDivider(new ColorDrawable( ThemeUtils.getThemeColor(getContext(), R.attr.odyssey_color_background_selected))); dlg.getListView().setDividerHeight(getResources().getDimensionPixelSize(R.dimen.list_divider_size)); return dlg; }
From source file:org.gateshipone.odyssey.dialogs.ChoosePlaylistDialog.java
/** * Create the dialog to choose to override an existing bookmark or to create a new bookmark. *//*from w w w. j a v a 2 s.c o m*/ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); mPlaylistsListViewAdapter = new SavedPlaylistsAdapter(getActivity()); builder.setTitle(R.string.dialog_choose_playlist) .setAdapter(mPlaylistsListViewAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { // open save dialog to create a new bookmark SaveDialog saveDialog = SaveDialog.newInstance(SaveDialog.OBJECTTYPE.PLAYLIST); saveDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "SaveDialog"); } else { // override existing bookmark PlaylistModel playlist = (PlaylistModel) mPlaylistsListViewAdapter.getItem(which); String objectTitle = playlist.getPlaylistName(); mSaveCallback.onSaveObject(objectTitle, SaveDialog.OBJECTTYPE.PLAYLIST); } } }).setNegativeButton(R.string.dialog_action_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog dont save object getDialog().cancel(); } }); // Prepare loader ( start new one or reuse old ) getLoaderManager().initLoader(0, getArguments(), this); // set divider AlertDialog dlg = builder.create(); dlg.getListView().setDivider(new ColorDrawable( ThemeUtils.getThemeColor(getContext(), R.attr.odyssey_color_background_selected))); dlg.getListView().setDividerHeight(getResources().getDimensionPixelSize(R.dimen.list_divider_size)); return dlg; }
From source file:org.gateshipone.malp.application.fragments.serverfragments.ChoosePlaylistDialog.java
/** * Create the dialog to choose to override an existing bookmark or to create a new bookmark. *///from w w w . j av a2 s .c o m @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Bundle args = getArguments(); if (null != args) { mShowNewEntry = args.getBoolean(EXTRA_SHOW_NEW_ENTRY); } // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); mPlaylistsListViewAdapter = new FileAdapter(getActivity(), false, false); builder.setTitle(getString(R.string.dialog_choose_playlist)) .setAdapter(mPlaylistsListViewAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (null == mSaveCallback) { return; } if (which == 0) { // open save dialog to create a new playlist mSaveCallback.onCreateNewObject(); } else { // override existing playlist MPDPlaylist playlist = (MPDPlaylist) mPlaylistsListViewAdapter.getItem(which); String objectTitle = playlist.getPath(); mSaveCallback.onSaveObject(objectTitle); } } }).setNegativeButton(R.string.dialog_action_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog don't save object getDialog().cancel(); } }); // Prepare loader ( start new one or reuse old ) getLoaderManager().initLoader(0, getArguments(), this); // set divider AlertDialog dlg = builder.create(); dlg.getListView().setDivider( new ColorDrawable(ThemeUtils.getThemeColor(getContext(), R.attr.malp_color_background_selected))); dlg.getListView().setDividerHeight(getResources().getDimensionPixelSize(R.dimen.list_divider_size)); return dlg; }
From source file:org.mozilla.gecko.RemoteClientsDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final String title = getArguments().getString(KEY_TITLE); final String positiveButtonText = getArguments().getString(KEY_POSITIVE_BUTTON_TEXT); final ChoiceMode choiceMode = ChoiceMode.values()[getArguments().getInt(KEY_CHOICE_MODE)]; final ArrayList<RemoteClient> clients = getArguments().getParcelableArrayList(KEY_CLIENTS); final Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(title);/* www. jav a 2 s . c om*/ final String[] clientNames = new String[clients.size()]; for (int i = 0; i < clients.size(); i++) { clientNames[i] = clients.get(i).name; } if (choiceMode == ChoiceMode.MULTIPLE) { builder.setMultiChoiceItems(clientNames, null, null); builder.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { if (which != Dialog.BUTTON_POSITIVE) { return; } final AlertDialog dialog = (AlertDialog) dialogInterface; final SparseBooleanArray checkedItemPositions = dialog.getListView().getCheckedItemPositions(); final ArrayList<RemoteClient> checked = new ArrayList<RemoteClient>(); for (int i = 0; i < clients.size(); i++) { if (checkedItemPositions.get(i)) { checked.add(clients.get(i)); } } notifyListener(checked); } }); } else { builder.setItems(clientNames, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int index) { final ArrayList<RemoteClient> checked = new ArrayList<RemoteClient>(); checked.add(clients.get(index)); notifyListener(checked); } }); } return builder.create(); }
From source file:de.vanita5.twittnuker.fragment.support.FileSelectorDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { mAdapter = new FilesAdapter(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setAdapter(mAdapter, this); builder.setTitle(R.string.pick_file); if (isPickDirectory()) { builder.setPositiveButton(android.R.string.ok, this); }//w ww .j av a2s.c o m final AlertDialog dialog = builder.create(); final ListView listView = dialog.getListView(); listView.setOnItemClickListener(this); return dialog; }
From source file:org.getlantern.firetweet.fragment.support.FileSelectorDialogFragment.java
@NonNull @Override//from ww w .j a va 2s . c o m public Dialog onCreateDialog(final Bundle savedInstanceState) { mAdapter = new FilesAdapter(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setAdapter(mAdapter, this); builder.setTitle(R.string.pick_file); builder.setNegativeButton(android.R.string.cancel, null); if (isPickDirectory()) { builder.setPositiveButton(android.R.string.ok, this); } final AlertDialog dialog = builder.create(); final ListView listView = dialog.getListView(); listView.setOnItemClickListener(this); return dialog; }
From source file:org.mariotaku.twidere.fragment.FileSelectorDialogFragment.java
@NonNull @Override// w w w . j ava 2s. c om public Dialog onCreateDialog(final Bundle savedInstanceState) { mAdapter = new FilesAdapter(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setAdapter(mAdapter, this); builder.setTitle(R.string.pick_file); builder.setNegativeButton(android.R.string.cancel, this); if (isPickDirectory()) { builder.setPositiveButton(android.R.string.ok, this); } final AlertDialog dialog = builder.create(); final ListView listView = dialog.getListView(); listView.setOnItemClickListener(this); return dialog; }
From source file:br.com.bioscada.apps.biotracks.fragments.ChooseActivityDialogFragment.java
@Override protected Dialog createDialog() { FragmentActivity fragmentActivity = getActivity(); packageManager = fragmentActivity.getPackageManager(); List<DisplayInfo> displayInfos = getDisplayInfos(fragmentActivity); ArrayAdapter<DisplayInfo> arrayAdapter = new ArrayAdapter<DisplayInfo>(fragmentActivity, R.layout.choose_activity_list_item, R.id.choose_activity_list_item_text1, displayInfos) { @Override/*from ww w . j av a 2 s . co m*/ public View getView(int position, View convertView, ViewGroup parent) { View view; ViewHolder viewHolder; if (convertView == null) { view = getActivity().getLayoutInflater().inflate(R.layout.choose_activity_list_item, parent, false); viewHolder = new ViewHolder(); viewHolder.text1 = (TextView) view.findViewById(R.id.choose_activity_list_item_text1); viewHolder.text2 = (TextView) view.findViewById(R.id.choose_activity_list_item_text2); viewHolder.icon = (ImageView) view.findViewById(R.id.choose_activity_list_item_icon); view.setTag(viewHolder); } else { view = convertView; viewHolder = (ViewHolder) view.getTag(); } DisplayInfo displayInfo = getItem(position); viewHolder.text1.setText(displayInfo.primaryLabel); boolean hasSecondaryLabel = displayInfo.secondaryLabel != null; viewHolder.text2.setVisibility(hasSecondaryLabel ? View.VISIBLE : View.GONE); if (hasSecondaryLabel) { viewHolder.text2.setText(displayInfo.secondaryLabel); } viewHolder.icon.setImageDrawable(displayInfo.icon); return view; } }; return new AlertDialog.Builder(fragmentActivity) .setSingleChoiceItems(arrayAdapter, 0, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { AlertDialog alertDialog = (AlertDialog) dialog; DisplayInfo displayInfo = (DisplayInfo) alertDialog.getListView().getItemAtPosition(which); ActivityInfo activityInfo = displayInfo.resolveInfo.activityInfo; dismiss(); caller.onChooseActivityDone(activityInfo.applicationInfo.packageName, activityInfo.name); } }).setTitle(R.string.share_track_share_url_title).create(); }
From source file:com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { packageManager = getActivity().getPackageManager(); List<DisplayInfo> displayInfos = getDisplayInfos(); ArrayAdapter<DisplayInfo> arrayAdapter = new ArrayAdapter<DisplayInfo>(getActivity(), R.layout.choose_activity_list_item, R.id.choose_activity_list_item_text1, displayInfos) { @Override//from www. j a v a2 s . co m public View getView(int position, View convertView, ViewGroup parent) { View view; if (convertView == null) { view = getActivity().getLayoutInflater().inflate(R.layout.choose_activity_list_item, parent, false); } else { view = convertView; } DisplayInfo displayInfo = getItem(position); TextView text1 = (TextView) view.findViewById(R.id.choose_activity_list_item_text1); TextView text2 = (TextView) view.findViewById(R.id.choose_activity_list_item_text2); ImageView icon = (ImageView) view.findViewById(R.id.choose_activity_list_item_icon); text1.setText(displayInfo.primaryLabel); if (displayInfo.secondaryLabel != null) { text2.setVisibility(View.VISIBLE); text2.setText(displayInfo.secondaryLabel); } else { text2.setVisibility(View.GONE); } icon.setImageDrawable(displayInfo.icon); return view; } }; return new AlertDialog.Builder(getActivity()) .setSingleChoiceItems(arrayAdapter, 0, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { AlertDialog alertDialog = (AlertDialog) dialog; DisplayInfo displayInfo = (DisplayInfo) alertDialog.getListView().getItemAtPosition(which); ActivityInfo activityInfo = displayInfo.resolveInfo.activityInfo; String packageName = activityInfo.applicationInfo.packageName; String className = activityInfo.name; long trackId = getArguments().getLong(KEY_TRACK_ID); String trackUrl = getArguments().getString(KEY_TRACK_URL); if (trackUrl == null) { SendRequest sendRequest = new SendRequest(trackId); sendRequest.setSendMaps(true); sendRequest.setNewMap(true); sendRequest.setSharingAppPackageName(packageName); sendRequest.setSharingAppClassName(className); Intent intent = IntentUtils.newIntent(getActivity(), ConfirmSharingActivity.class) .putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest); startActivity(intent); dismiss(); } else { Intent intent = IntentUtils.newShareUrlIntent(getActivity(), trackId, trackUrl, packageName, className); startActivity(intent); getActivity().finish(); } } }).setTitle(R.string.share_track_picker_title).create(); }