Example usage for android.app AlertDialog.Builder setTitle

List of usage examples for android.app AlertDialog.Builder setTitle

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setTitle.

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:Main.java

public static AlertDialog newMessageDialog(final Activity activity, String dialogTitle, String screenMessage,
        int iconResourceId) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setCancelable(false);/*from   w w w  .  j  a  va 2 s.com*/
    builder.setPositiveButton("Okay", new OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    builder.setTitle(dialogTitle);
    builder.setMessage(screenMessage);
    builder.setIcon(iconResourceId);

    return builder.create();
}

From source file:Main.java

/**
 * Creates a new AlertDialog to display a simple message
 * /*from   ww  w.  j  a  va 2 s .c  o m*/
 * @param context
 * @param dialogTitle
 * @param screenMessage
 * @param iconResourceId
 * @return
 */
public static AlertDialog newMessageDialog(final Context context, String dialogTitle, String screenMessage,
        int iconResourceId) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);
    builder.setPositiveButton("Okay", new OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    builder.setTitle(dialogTitle);
    builder.setMessage(screenMessage);
    builder.setIcon(iconResourceId);

    return builder.create();
}

From source file:org.cocos2dx.lib.CCUtils.java

static void showConfirmDialog(final String title, final String text, final String positiveButton,
        final String negativeButton, final long okFunc, final long cancelFunc) {
    nativeRetain(okFunc);//  ww w  .j av  a  2s  .co  m
    nativeRetain(cancelFunc);

    final Cocos2dxActivity act = (Cocos2dxActivity) Cocos2dxActivity.getContext();
    act.runOnUiThread(new Runnable() {
        public void run() {
            AlertDialog.Builder builder = new Builder(act);
            if (title != null)
                builder.setTitle(title);
            if (text != null)
                builder.setMessage(text);
            if (positiveButton != null) {
                builder.setPositiveButton(positiveButton, new OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        act.runOnGLThread(new Runnable() {
                            @Override
                            public void run() {
                                nativeExecuteCallFunc(okFunc);
                                nativeRelease(okFunc);
                            }
                        });
                    }
                });
            }
            if (negativeButton != null) {
                builder.setNegativeButton(negativeButton, new OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        act.runOnGLThread(new Runnable() {
                            @Override
                            public void run() {
                                nativeExecuteCallFunc(cancelFunc);
                                nativeRelease(cancelFunc);
                            }
                        });
                    }
                });
            }

            builder.show();
        }
    });
}

From source file:com.escabe.TraktApi.java

public static boolean Login(String u, String p) {
    username = u;//from  www  .  ja  v  a  2  s  . c om
    password = p;
    JSONObject data = getDataObjectFromJSON("", true);
    if (data == null) {
        AlertDialog.Builder alert = new AlertDialog.Builder(trakt.instance);
        alert.setTitle("Trakt.tv");
        alert.setMessage("Login Failed!\nPlease check login details.");
        alert.setIcon(android.R.drawable.ic_dialog_alert);
        alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
                trakt.instance.myflipper.FlipTo(MyView.SETTINGS);
            }
        });
        alert.show();
        return false;
    } else {
        return true;
    }
}

From source file:com.fuzz.android.limelight.model.ChapterTransition.java

public static void getDrawerPosition() {
    LayoutInflater inflater = LimeLight.getActivity().getLayoutInflater();
    View drawerView = inflater.inflate(R.layout.choose_drawer_item, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(LimeLight.getActivity());
    builder.setTitle(R.string.choose_drawer_item);
    builder.setView(drawerView);/*from w w  w . j  a v  a2s . c  o  m*/

    final Spinner positionSpinner = (Spinner) drawerView.findViewById(R.id.positionSpinner);

    ArrayList<String> items = new ArrayList<String>();
    for (int i = 0; i < LimeLight.getDrawerList().getAdapter().getCount(); i++) {
        items.add(i + "");
    }

    ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(LimeLight.getActivity(),
            android.R.layout.simple_spinner_dropdown_item, items);

    positionSpinner.setAdapter(spinnerArrayAdapter);

    positionSpinner.setSelection(mDrawerItemPosition);

    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            mDrawerItemPosition = Integer.valueOf(positionSpinner.getSelectedItem().toString());
        }
    });

    builder.setNegativeButton(R.string.cancel, null);

    builder.create();
    builder.show();
}

From source file:net.vexelon.bgrates.Utils.java

/**
 * Display an alert dialog/*from ww w .j  av a  2 s .c  om*/
 * @param context
 * @param messageResId
 * @param titleResId
 */
public static void showAlertDialog(Context context, int messageResId, int titleResId) {

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context);
    alertBuilder.setTitle(context.getResources().getString(titleResId))
            .setMessage(context.getResources().getString(messageResId)).setIcon(R.drawable.alert)
            .setOnKeyListener(new DialogInterface.OnKeyListener() {

                @Override
                public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                    dialog.dismiss();
                    return false;
                }
            }).create().show();
}

From source file:Main.java

public static AlertDialog newMessageDialog(Context context, String s, String s1, int i) {
    android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(context);
    builder.setCancelable(false);//  w w  w.j a  v a2 s .  c  o m
    builder.setPositiveButton("Okay", new android.content.DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialoginterface, int j) {
            dialoginterface.dismiss();
        }

    });
    builder.setTitle(s);
    builder.setMessage(s1);
    builder.setIcon(i);
    return builder.create();
}

From source file:com.spoiledmilk.cykelsuperstier.navigation.SMRouteNavigationActivity.java

public static void showRouteNoBreakDialog(final Context context, AlertDialog dialog) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(CykelsuperstierApplication.getString("no_route"));
    builder.setMessage(CykelsuperstierApplication.getString("cannot_broken"));
    builder.setPositiveButton("OK", new OnClickListener() {
        @Override/*  ww w .  jav  a  2s  .c o m*/
        public void onClick(DialogInterface dialog, int arg1) {
            dialog.dismiss();
        }
    });
    dialog = builder.create();
    dialog.setCancelable(false);
    dialog.show();
}

From source file:li.klass.fhem.adapter.devices.genericui.AvailableTargetStatesDialogUtil.java

public static <D extends FhemDevice<D>> void showSwitchOptionsMenu(final Context context, final D device,
        final TargetStateSelectedCallback callback) {
    AlertDialog.Builder contextMenu = new AlertDialog.Builder(context);
    contextMenu.setTitle(context.getResources().getString(R.string.switchDevice));
    final List<String> setOptions = device.getSetList().getSortedKeys();
    final String[] eventMapOptions = device.getAvailableTargetStatesEventMapTexts();

    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override/*from ww w.  j  a  va  2  s .c o  m*/
        public void onClick(DialogInterface dialog, int position) {
            final String option = setOptions.get(position);

            if (handleSelectedOption(context, device, option, callback))
                return;

            dialog.dismiss();
        }
    };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, R.layout.list_item_with_arrow,
            eventMapOptions) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = View.inflate(context, R.layout.list_item_with_arrow, null);
            }
            TextView textView = (TextView) convertView.findViewById(R.id.text);
            ImageView imageView = (ImageView) convertView.findViewById(R.id.image);

            textView.setText(getItem(position));

            String setOption = setOptions.get(position);
            SetList setList = device.getSetList();
            final SetListValue setListValue = setList.get(setOption);

            imageView.setVisibility(setListValue instanceof SetListGroupValue ? VISIBLE : GONE);

            return convertView;
        }
    };
    contextMenu.setAdapter(adapter, clickListener);

    contextMenu.show();
}

From source file:net.vexelon.myglob.utils.Utils.java

/**
 * Create an alert dialog without showing it on screen
 * @param context/*from   ww  w . ja va2s.co  m*/
 * @param message
 * @param titleResId
 * @return
 */
public static AlertDialog createAlertDialog(Context context, String message, String title) {

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context);

    return alertBuilder.setTitle(title).setMessage(message).setIcon(R.drawable.ic_dialog_alert)
            .setOnKeyListener(new DialogInterface.OnKeyListener() {

                @Override
                public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                    dialog.dismiss();
                    return false;
                }
            }).create();
}