Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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);
        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();
    }
}