AlertDialog.Builder setSingleChoiceItems - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AlertDialog.Builder setSingleChoiceItems method.

This code example shows how to use the following methods:setSingleChoiceItems
		} 
	} 
 
	@Override 
	protected void onPrepareDialogBuilder(final Builder builder) {
		builder.setSingleChoiceItems(getEntries(), mSelectedItem, new OnClickListener() {
 
			@Override 
			public void onClick(final DialogInterface dialog, final int which) {
				mSelectedItem = which;
				if (mMediaPlayer != null) {
					if (mMediaPlayer.isPlaying()) {
						mMediaPlayer.stop();
					} 
					mMediaPlayer.release();
				} 
				mMediaPlayer = new MediaPlayer();
				mMediaPlayer.setLooping(false);
				final String ringtone = mValues[mSelectedItem];
				final Uri def_uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
5
CodeRank
This code example shows how to use the following methods:create, setSingleChoiceItems
                return true; 
            } 
        }; 
         
        // Create and show the dialog 
        mBuilder.setSingleChoiceItems( mOptions, checkedItem, clickListener );
        AlertDialog dialog = mBuilder.create();
        dialog.getListView().setOnItemLongClickListener( longClickListener );
        dialog.show();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:create, setNegativeButton, setPositiveButton, setSingleChoiceItems, setTitle
        private String[] menuItem = {"One", "Two", "Three"};
        private int index;
 
        public void execute() { 
 
            Builder builder = new AlertDialog.Builder(MenuActivity.this);
            builder.setTitle("Save...");
 
            builder.setSingleChoiceItems(menuItem, 0, new OnClickListener() {
 
                public void onClick(DialogInterface dialog, int which) {
                    index = which;
                } 
            }); 
            builder.setPositiveButton("Yes", new OnClickListener() {
 
                public void onClick(DialogInterface dialog, int which) {
                    Toast.makeText(MenuActivity.this, menuItem[index] + " Saved", Toast.LENGTH_LONG)
                            .show();
                } 

6
CodeRank
This code example shows how to use the following methods:create, setSingleChoiceItems
    finish(); 
  } 
 
  protected void h() 
  { 
    AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
    ArrayList localArrayList = a(new ArrayList());
    if (localArrayList != null)
      localBuilder.setSingleChoiceItems(new com.avg.ui.general.b.e(this, 0, false, (String[])localArrayList.toArray(new String[localArrayList.size()]), false), 0, new g(this));
    AlertDialog localAlertDialog = localBuilder.create();
    localAlertDialog.setCanceledOnTouchOutside(false);
    localAlertDialog.show();
  } 
 
  public void i() 
  { 
    g(); 
  } 
 
  protected abstract Class j();
5
CodeRank
This code example shows how to use the following methods:setPositiveButton, setSingleChoiceItems
    updateSummary(); 
  } 
 
  @Override 
  protected void onPrepareDialogBuilder(final Builder builder) {
    builder.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() {
 
      @Override 
      public void onClick(final DialogInterface dialog, final int which) {
        calendarId = adapter.getItemId(which);
        CalendarListPreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
        dialog.dismiss();
      } 
    }); 
    builder.setPositiveButton(null, null);
  } 
 
  @Override 
  protected void onDialogClosed(final boolean positiveResult) {
    super.onDialogClosed(positiveResult);
5
CodeRank
This code example shows how to use the following methods:setPositiveButton, setSingleChoiceItems
	@Override 
	protected void onPrepareDialogBuilder(final Builder builder)
	{ 
		super.onPrepareDialogBuilder(builder);
 
		builder.setSingleChoiceItems(getEntries(), findIndexOfValue(getValue()), this);
		builder.setPositiveButton("Ok", null);
	} 
 
	@Override 
	public void onClick(final DialogInterface dialog, final int which)
	{ 
		EntryIndex = which;
 
		if (EntryIndex < 0)
			return; 
 
		final String pattern = (String) getEntryValues()[EntryIndex];
		final Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
 
4
CodeRank
This code example shows how to use the following methods:setPositiveButton, setSingleChoiceItems
 
	//��д���򷽷�������һ��OK��ť 
	@Override 
	protected void onPrepareDialogBuilder(Builder builder) {
		//super.onPrepareDialogBuilder(builder);//���ܵ��ø��������򷽷������������б������رնԻ��� 
		builder.setSingleChoiceItems(entries, indexOfValue, new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				Log.v(LOGTAG, String.valueOf(which));
				selectedId=which;
			} 
		}); 
		//builder.setPositiveButton(null, null);//ListPreferenceԴ��������������д�ģ�����������Ҫ��д 
		builder.setPositiveButton(getPositiveButtonText()==null?"OK":getPositiveButtonText(), new DialogInterface.OnClickListener() {
			@Override 
			public void onClick(DialogInterface paramDialogInterface, int paramInt) {
				if(selectedId>=0){
					setSummary(entries[selectedId]);
					paramDialogInterface.dismiss();
					newListPreference.this.persistString(entryValues[selectedId].toString());
					newListPreference.this.callChangeListener(entryValues[selectedId]);
5
CodeRank
This code example shows how to use the following methods:setSingleChoiceItems
	} 
 
	@Override 
	protected void onPrepareDialogBuilder(final Builder builder) {
 
		builder.setSingleChoiceItems(getEntries(), mSelectedItem, new OnClickListener() {
 
			@Override 
			public void onClick(final DialogInterface dialog, final int which) {
				mSelectedItem = which;
				if (mMediaPlayer != null) {
					if (mMediaPlayer.isPlaying()) {
						mMediaPlayer.stop();
					} 
					mMediaPlayer.release();
				} 
				mMediaPlayer = new MediaPlayer();
				mMediaPlayer.setLooping(false);
				final String ringtone = mValues[mSelectedItem];
				final Uri def_uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
4
CodeRank
This code example shows how to use the following methods:setSingleChoiceItems
		{ 
			throw new IllegalStateException("SnoozePreference requires an entries array.");
		} 
		mSnoozeTime = mSettings.getSnoozeTime();
		int index = Math.min(Math.max(mSnoozeTime / 5, 0), entries.length - 1);
		builder.setSingleChoiceItems(entries, index, new DialogInterface.OnClickListener()
		{ 
			public void onClick(DialogInterface dialog, int which)
			{ 
				if (which == 0)
					mSnoozeTime = 0;
				else 
					mSnoozeTime = which * 5;
			} 
		}); 
	} 
} 
4
CodeRank
This code example shows how to use the following methods:setSingleChoiceItems
     * 
     * @return This Builder object to allow for chaining of calls to set methods 
     */ 
    public AlertDialogBuilderWrapper setSingleChoiceItems(int itemsId, int checkedItem, 
            final OnClickListener listener) {
        builder.setSingleChoiceItems(itemsId, checkedItem, listener);
        return this;
    } 
     
    /** 
     * Set a list of items to be displayed in the dialog as the content, you will be notified of 
     * the selected item via the supplied listener. The list will have a check mark displayed to 
     * the right of the text for the checked item. Clicking on an item in the list will not 
     * dismiss the dialog. Clicking on a button will dismiss the dialog. 
     *  
     * @param cursor the cursor to retrieve the items from. 
     * @param checkedItem specifies which item is checked. If -1 no items are checked. 
     * @param labelColumn The column name on the cursor containing the string to display in the 
     *        label. 
     * @param listener notified when an item on the list is clicked. The dialog will not be 
3
CodeRank

Related AlertDialog.Builder setSingleChoiceItems Questions & Answers:

setSingleChoiceItems Method Overview
Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.
See Code Examples for other Android AlertDialog.Builder Methods: