get Alarm Ringtones Dialog - Android User Interface

Android examples for User Interface:Dialog

Description

get Alarm Ringtones Dialog

Demo Code


//package com.java2s;
import android.app.Activity;
import android.app.AlertDialog;

import android.content.DialogInterface;

import android.widget.ArrayAdapter;
import java.util.Collection;

public class Main {
    public static void getRingtonesDialog(Activity activity,
            Collection<String> items, int selected,
            DialogInterface.OnClickListener itemClickListener,
            DialogInterface.OnClickListener okClickListener,
            final DialogInterface.OnClickListener cancelClickListener) {
        AlertDialog.Builder builderSingle = new AlertDialog.Builder(
                activity);//from   w w w . java  2  s  .c  o m
        builderSingle.setTitle("Select Ringtone");
        final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(
                activity, android.R.layout.select_dialog_singlechoice);
        arrayAdapter.addAll(items);

        builderSingle.setNegativeButton(android.R.string.cancel,
                cancelClickListener);

        builderSingle.setPositiveButton(android.R.string.ok,
                okClickListener);

        builderSingle.setSingleChoiceItems(arrayAdapter, selected,
                itemClickListener);

        builderSingle.setCancelable(false);

        builderSingle.show();
    }
}

Related Tutorials