Example usage for android.app Dialog setTitle

List of usage examples for android.app Dialog setTitle

Introduction

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

Prototype

public void setTitle(@StringRes int titleId) 

Source Link

Document

Set the title text for this dialog's window.

Usage

From source file:net.mypapit.mobile.myrepeater.RepeaterListActivity.java

public void showDialog() throws NameNotFoundException {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.about_dialog);
    dialog.setTitle("About Repeater.MY " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
    dialog.setCancelable(true);//w  w w.  j ava  2s .co  m

    // text
    TextView text = (TextView) dialog.findViewById(R.id.tvAbout);
    text.setText(R.string.txtLicense);

    // icon image
    ImageView img = (ImageView) dialog.findViewById(R.id.ivAbout);
    img.setImageResource(R.drawable.ic_launcher);

    dialog.show();

}

From source file:org.thoughtland.xlocation.ActivityApp.java

@SuppressLint("InflateParams")
public static void showHelp(ActivityBase context, View parent, Hook hook) {
    // Build dialog
    Dialog dlgHelp = new Dialog(context);
    dlgHelp.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dlgHelp.setTitle(R.string.app_name);
    dlgHelp.setContentView(R.layout.helpfunc);
    dlgHelp.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, context.getThemed(R.attr.icon_launcher));
    dlgHelp.setCancelable(true);/*from  w  w w .ja  va  2  s  . co  m*/

    // Set title
    TextView tvTitle = (TextView) dlgHelp.findViewById(R.id.tvTitle);
    tvTitle.setText(hook.getName());

    // Set info
    TextView tvInfo = (TextView) dlgHelp.findViewById(R.id.tvInfo);
    tvInfo.setText(Html.fromHtml(hook.getAnnotation()));
    tvInfo.setMovementMethod(LinkMovementMethod.getInstance());

    // Set permissions
    String[] permissions = hook.getPermissions();
    if (permissions != null && permissions.length > 0)
        if (!permissions[0].equals("")) {
            TextView tvPermissions = (TextView) dlgHelp.findViewById(R.id.tvPermissions);
            tvPermissions.setText(Html.fromHtml(TextUtils.join("<br />", permissions)));
        }

    dlgHelp.show();
}

From source file:org.ohmage.reminders.types.location.LocTrigMapsActivity.java

private void showHelpDialog() {
    Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.trigger_loc_maps_tips);
    dialog.setTitle(R.string.trigger_loc_defining_locations);
    dialog.setOwnerActivity(this);
    dialog.show();//from ww  w.java  2s  .  co m

    WebView webView = (WebView) dialog.findViewById(R.id.web_view);
    webView.loadUrl("file:///android_res/raw/trigger_loc_maps_help.html");

    CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.check_do_not_show);
    checkBox.setChecked(shouldSkipToolTip());
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            SharedPreferences pref = LocTrigMapsActivity.this.getSharedPreferences(TOOL_TIP_PREF_NAME,
                    Context.MODE_PRIVATE);

            SharedPreferences.Editor editor = pref.edit();
            editor.putBoolean(KEY_TOOL_TIP_DO_NT_SHOW, isChecked);
            editor.commit();
        }
    });

    Button button = (Button) dialog.findViewById(R.id.button_close);
    button.setTag(dialog);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Object tag = v.getTag();
            if (tag != null && tag instanceof Dialog) {
                ((Dialog) tag).dismiss();
            }
        }
    });
}

From source file:com.aware.ui.ESM_UI.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    //      getActivity().getWindow().setType(WindowManager.LayoutParams.TYPE_PRIORITY_PHONE);
    //      getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    //        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    //        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    builder = new AlertDialog.Builder(getActivity());
    inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);

    TAG = Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG).length() > 0
            ? Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG)
            : TAG;//from  w w w.ja  v a 2  s.  c om

    Cursor visible_esm = getActivity().getContentResolver().query(ESM_Data.CONTENT_URI, null,
            ESM_Data.STATUS + "=" + ESM.STATUS_NEW, null, ESM_Data.TIMESTAMP + " ASC LIMIT 1");
    if (visible_esm != null && visible_esm.moveToFirst()) {
        esm_id = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data._ID));

        //Fixed: set the esm as not new anymore, to avoid displaying the same ESM twice due to changes in orientation
        ContentValues update_state = new ContentValues();
        update_state.put(ESM_Data.STATUS, ESM.STATUS_VISIBLE);
        getActivity().getContentResolver().update(ESM_Data.CONTENT_URI, update_state,
                ESM_Data._ID + "=" + esm_id, null);

        esm_type = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.TYPE));
        expires_seconds = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.EXPIRATION_THREASHOLD));

        builder.setTitle(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.TITLE)));

        View ui = null;
        switch (esm_type) {
        case ESM.TYPE_ESM_TEXT:
            ui = inflater.inflate(R.layout.esm_text, null);
            break;
        case ESM.TYPE_ESM_RADIO:
            ui = inflater.inflate(R.layout.esm_radio, null);
            break;
        case ESM.TYPE_ESM_CHECKBOX:
            ui = inflater.inflate(R.layout.esm_checkbox, null);
            break;
        case ESM.TYPE_ESM_LIKERT:
            ui = inflater.inflate(R.layout.esm_likert, null);
            break;
        case ESM.TYPE_ESM_QUICK_ANSWERS:
            ui = inflater.inflate(R.layout.esm_quick, null);
            break;
        }

        final View layout = ui;
        builder.setView(layout);
        current_dialog = builder.create();
        sContext = current_dialog.getContext();

        TextView esm_instructions = (TextView) layout.findViewById(R.id.esm_instructions);
        esm_instructions.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.INSTRUCTIONS)));

        switch (esm_type) {
        case ESM.TYPE_ESM_TEXT:
            final EditText feedback = (EditText) layout.findViewById(R.id.esm_feedback);
            Button cancel_text = (Button) layout.findViewById(R.id.esm_cancel);
            cancel_text.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0);
                    current_dialog.cancel();
                }
            });
            Button submit_text = (Button) layout.findViewById(R.id.esm_submit);
            submit_text.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT)));
            submit_text.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0);

                    if (expires_seconds > 0 && expire_monitor != null)
                        expire_monitor.cancel(true);

                    ContentValues rowData = new ContentValues();
                    rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());
                    rowData.put(ESM_Data.ANSWER, feedback.getText().toString());
                    rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED);

                    sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData,
                            ESM_Data._ID + "=" + esm_id, null);

                    Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
                    getActivity().sendBroadcast(answer);

                    if (Aware.DEBUG)
                        Log.d(TAG, "Answer:" + rowData.toString());

                    current_dialog.dismiss();
                }
            });
            break;
        case ESM.TYPE_ESM_RADIO:
            try {
                final RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio);
                final JSONArray radios = new JSONArray(
                        visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.RADIOS)));

                for (int i = 0; i < radios.length(); i++) {
                    final RadioButton radioOption = new RadioButton(getActivity());
                    radioOption.setId(i);
                    radioOption.setText(radios.getString(i));
                    radioOptions.addView(radioOption);

                    if (radios.getString(i).equals("Other")) {
                        radioOption.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                final Dialog editOther = new Dialog(getActivity());
                                editOther.setTitle("Can you be more specific, please?");
                                editOther.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
                                editOther.getWindow().setGravity(Gravity.TOP);
                                editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT,
                                        LayoutParams.WRAP_CONTENT);

                                LinearLayout editor = new LinearLayout(getActivity());
                                editor.setOrientation(LinearLayout.VERTICAL);

                                editOther.setContentView(editor);
                                editOther.show();

                                final EditText otherText = new EditText(getActivity());
                                editor.addView(otherText);

                                Button confirm = new Button(getActivity());
                                confirm.setText("OK");
                                confirm.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        if (otherText.length() > 0)
                                            radioOption.setText(otherText.getText());
                                        inputManager.hideSoftInputFromWindow(otherText.getWindowToken(), 0);
                                        editOther.dismiss();
                                    }
                                });
                                editor.addView(confirm);
                            }
                        });
                    }
                }
                Button cancel_radio = (Button) layout.findViewById(R.id.esm_cancel);
                cancel_radio.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        current_dialog.cancel();
                    }
                });
                Button submit_radio = (Button) layout.findViewById(R.id.esm_submit);
                submit_radio.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT)));
                submit_radio.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        if (expires_seconds > 0 && expire_monitor != null)
                            expire_monitor.cancel(true);

                        ContentValues rowData = new ContentValues();
                        rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());

                        RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio);
                        if (radioOptions.getCheckedRadioButtonId() != -1) {
                            RadioButton selected = (RadioButton) radioOptions
                                    .getChildAt(radioOptions.getCheckedRadioButtonId());
                            rowData.put(ESM_Data.ANSWER, selected.getText().toString());
                        }
                        rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED);

                        sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData,
                                ESM_Data._ID + "=" + esm_id, null);

                        Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
                        getActivity().sendBroadcast(answer);

                        if (Aware.DEBUG)
                            Log.d(TAG, "Answer:" + rowData.toString());

                        current_dialog.dismiss();
                    }
                });
            } catch (JSONException e) {
                e.printStackTrace();
            }
            break;
        case ESM.TYPE_ESM_CHECKBOX:
            try {
                final LinearLayout checkboxes = (LinearLayout) layout.findViewById(R.id.esm_checkboxes);
                final JSONArray checks = new JSONArray(
                        visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.CHECKBOXES)));

                for (int i = 0; i < checks.length(); i++) {
                    final CheckBox checked = new CheckBox(getActivity());
                    checked.setText(checks.getString(i));
                    checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                        @Override
                        public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) {
                            if (isChecked) {
                                if (buttonView.getText().equals("Other")) {
                                    checked.setOnClickListener(new View.OnClickListener() {
                                        @Override
                                        public void onClick(View v) {
                                            final Dialog editOther = new Dialog(getActivity());
                                            editOther.setTitle("Can you be more specific, please?");
                                            editOther.getWindow()
                                                    .setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
                                            editOther.getWindow().setGravity(Gravity.TOP);
                                            editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT,
                                                    LayoutParams.WRAP_CONTENT);

                                            LinearLayout editor = new LinearLayout(getActivity());
                                            editor.setOrientation(LinearLayout.VERTICAL);
                                            editOther.setContentView(editor);
                                            editOther.show();

                                            final EditText otherText = new EditText(getActivity());
                                            editor.addView(otherText);

                                            Button confirm = new Button(getActivity());
                                            confirm.setText("OK");
                                            confirm.setOnClickListener(new View.OnClickListener() {
                                                @Override
                                                public void onClick(View v) {
                                                    if (otherText.length() > 0) {
                                                        inputManager.hideSoftInputFromWindow(
                                                                otherText.getWindowToken(), 0);
                                                        selected_options
                                                                .remove(buttonView.getText().toString());
                                                        checked.setText(otherText.getText());
                                                        selected_options.add(otherText.getText().toString());
                                                    }
                                                    editOther.dismiss();
                                                }
                                            });
                                            editor.addView(confirm);
                                        }
                                    });
                                } else {
                                    selected_options.add(buttonView.getText().toString());
                                }
                            } else {
                                selected_options.remove(buttonView.getText().toString());
                            }
                        }
                    });
                    checkboxes.addView(checked);
                }
                Button cancel_checkbox = (Button) layout.findViewById(R.id.esm_cancel);
                cancel_checkbox.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        current_dialog.cancel();
                    }
                });
                Button submit_checkbox = (Button) layout.findViewById(R.id.esm_submit);
                submit_checkbox.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT)));
                submit_checkbox.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        if (expires_seconds > 0 && expire_monitor != null)
                            expire_monitor.cancel(true);

                        ContentValues rowData = new ContentValues();
                        rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());

                        if (selected_options.size() > 0) {
                            rowData.put(ESM_Data.ANSWER, selected_options.toString());
                        }

                        rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED);

                        sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData,
                                ESM_Data._ID + "=" + esm_id, null);

                        Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
                        getActivity().sendBroadcast(answer);

                        if (Aware.DEBUG)
                            Log.d(TAG, "Answer:" + rowData.toString());

                        current_dialog.dismiss();
                    }
                });
            } catch (JSONException e) {
                e.printStackTrace();
            }
            break;
        case ESM.TYPE_ESM_LIKERT:
            final RatingBar ratingBar = (RatingBar) layout.findViewById(R.id.esm_likert);
            ratingBar.setMax(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX)));
            ratingBar.setStepSize(
                    (float) visible_esm.getDouble(visible_esm.getColumnIndex(ESM_Data.LIKERT_STEP)));
            ratingBar.setNumStars(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX)));

            TextView min_label = (TextView) layout.findViewById(R.id.esm_min);
            min_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MIN_LABEL)));

            TextView max_label = (TextView) layout.findViewById(R.id.esm_max);
            max_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX_LABEL)));

            Button cancel = (Button) layout.findViewById(R.id.esm_cancel);
            cancel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    current_dialog.cancel();
                }
            });
            Button submit = (Button) layout.findViewById(R.id.esm_submit);
            submit.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT)));
            submit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (expires_seconds > 0 && expire_monitor != null)
                        expire_monitor.cancel(true);

                    ContentValues rowData = new ContentValues();
                    rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());
                    rowData.put(ESM_Data.ANSWER, ratingBar.getRating());
                    rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED);

                    sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData,
                            ESM_Data._ID + "=" + esm_id, null);

                    Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
                    getActivity().sendBroadcast(answer);

                    if (Aware.DEBUG)
                        Log.d(TAG, "Answer:" + rowData.toString());

                    current_dialog.dismiss();
                }
            });
            break;
        case ESM.TYPE_ESM_QUICK_ANSWERS:
            try {
                final JSONArray answers = new JSONArray(
                        visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.QUICK_ANSWERS)));
                final LinearLayout answersHolder = (LinearLayout) layout.findViewById(R.id.esm_answers);

                //If we have more than 3 possibilities, better that the UI is vertical for UX
                if (answers.length() > 3) {
                    answersHolder.setOrientation(LinearLayout.VERTICAL);
                }

                for (int i = 0; i < answers.length(); i++) {
                    final Button answer = new Button(getActivity());
                    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                            LayoutParams.WRAP_CONTENT, 1.0f);
                    answer.setLayoutParams(params);
                    answer.setText(answers.getString(i));
                    answer.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {

                            if (expires_seconds > 0 && expire_monitor != null)
                                expire_monitor.cancel(true);

                            ContentValues rowData = new ContentValues();
                            rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());
                            rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED);
                            rowData.put(ESM_Data.ANSWER, (String) answer.getText());

                            sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData,
                                    ESM_Data._ID + "=" + esm_id, null);

                            Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
                            getActivity().sendBroadcast(answer);

                            if (Aware.DEBUG)
                                Log.d(TAG, "Answer:" + rowData.toString());

                            current_dialog.dismiss();
                        }
                    });
                    answersHolder.addView(answer);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
            break;
        }
    }
    if (visible_esm != null && !visible_esm.isClosed())
        visible_esm.close();

    //Start dialog visibility threshold
    if (expires_seconds > 0) {
        expire_monitor = new ESMExpireMonitor(System.currentTimeMillis(), expires_seconds, esm_id);
        expire_monitor.execute();
    }

    //Fixed: doesn't dismiss the dialog if touched outside or ghost touches
    current_dialog.setCanceledOnTouchOutside(false);

    return current_dialog;
}

From source file:com.hp.map.CustomerMapActivity.java

public void menuDialog() {
    final Dialog dialog = new Dialog(this);
    LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = li.inflate(R.layout.menu_dialog, null, false);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(v);/*from   w  ww .  java  2s .com*/

    dialog.setTitle("Danh mc chnh");

    Display display = getWindowManager().getDefaultDisplay();

    dialog.getWindow().setLayout(2 * display.getWidth() / 3, LayoutParams.FILL_PARENT);
    dialog.getWindow().getAttributes().gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;

    lv = (ListView) dialog.findViewById(R.id.menu_list_view);

    lv.setAdapter(
            new DialogArrayAdapter(context, android.R.layout.simple_list_item_1, DetailListData.MENU_LIST));
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            DetailsList selectedValue = (DetailsList) lv.getAdapter().getItem(arg2);
            if (selectedValue.activityClass != null) {
                //if sigout
                if (selectedValue.activityClass == LoginActivity.class) {
                    //LoginActivity.threadLooper.quit();
                }
                startActivity(new Intent(context, selectedValue.activityClass));
            }
        }
    });

    dialog.show();

    //      ImageView iv = (ImageView)dialog.findViewById(R.id.menu_list_view);
    //      iv.setImageResource(1);
}

From source file:com.eurotong.orderhelperandroid.OrderMenuActivity.java

@Override
public void onClick(View v) {
    if (v.getId() == R.id.btnGoHome) {
        GotoTableOrderView();/*  ww  w  .  ja  va 2 s  .  c om*/
        //finish();
    }
    if (v.getId() == R.id.btnPrint) {
        // custom dialog
        final Dialog dialog = new Dialog(context);

        dialog.setContentView(R.layout.print_command_selection);
        dialog.setTitle(R.string.msg_please_select_operation);

        // set the custom dialog components - text, image and button
        Button btnPrintBill = (Button) dialog.findViewById(R.id.btnPrintBill);
        Button btnPrintKitchen = (Button) dialog.findViewById(R.id.btnPrintKitchen);
        Button btnExit = (Button) dialog.findViewById(R.id.btnExit);
        Button btnPrintBar = (Button) dialog.findViewById(com.eurotong.orderhelperandroid.R.id.btnPrintBar);
        Button btnPrintPreview = (Button) dialog
                .findViewById(com.eurotong.orderhelperandroid.R.id.btnPrintPreview);
        if (!User.Current().HasRight(Define.UR_DEBUG_PRINT_LAYOUT)) {
            btnPrintPreview.setVisibility(View.GONE);
        }
        // if button is clicked, close the custom dialog
        btnPrintBill.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (User.Current().HasRight(Define.UR_PRINT)) {
                    DoPrintPos(_table, PrintLayout.Current(), Setting.Current().NumberOfPrints);
                    dialog.dismiss();
                }
            }
        });

        btnPrintKitchen.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (User.Current().HasRight(Define.UR_PRINT_KITCHEN)) {
                    DoPrintPos(_table, PrintLayout.KitchenLayout(), Setting.Current().NumberOfPrintsKitchen);
                    dialog.dismiss();
                }
            }
        });

        btnPrintBar.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (User.Current().HasRight(Define.UR_PRINT_BAR)) {
                    DoPrintPos(_table, PrintLayout.BarLayout(), Setting.Current().NumberOfPrintsBar);
                    dialog.dismiss();
                }
            }
        });
        btnPrintPreview.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(context, PrintPreview.class);
                i.putExtra(Define.TABLE_NR, _table.TableNr);
                startActivity(i);
                dialog.dismiss();
            }
        });
        btnExit.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
    }
    if (v.getId() == R.id.btnExtra) {
        // custom dialog
        final Dialog dialog = new Dialog(context);

        dialog.setContentView(R.layout.table_order_extra);
        dialog.setTitle(R.string.msg_please_select_operation);

        // set the custom dialog components - text, image and button
        Button btnViewTableDetail = (Button) dialog.findViewById(R.id.btnViewTableDetail);
        Button btnDeleteTable = (Button) dialog.findViewById(R.id.btnDeleteTable);
        Button btnExit = (Button) dialog.findViewById(com.eurotong.orderhelperandroid.R.id.btnExit);
        Button btnAddChildTable = (Button) dialog
                .findViewById(com.eurotong.orderhelperandroid.R.id.btnAddChildTable);

        // if button is clicked, close the custom dialog
        btnViewTableDetail.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(context, TableDetailActivity.class);
                i.putExtra(Define.TABLE_NR, _table.TableNr);
                startActivity(i);
                dialog.dismiss();
            }
        });

        btnAddChildTable.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Table table;
                if (_table.ParentTable != null) {
                    table = _table.ParentTable.CreateChildTable();
                } else {
                    table = _table.CreateChildTable();
                }
                TableHelper.TableList().add(table);
                TableHelper.SaveTablesToStorage();
                _table = table;
                InitVMMenuGroup();
                ShowCurrentOrders();
                dialog.dismiss();
            }
        });

        btnDeleteTable.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Builder confirmDeleteTableDialog = new AlertDialog.Builder(context);
                confirmDeleteTableDialog.setTitle(R.string.msg_are_you_sure_to_delete_this_order);
                confirmDeleteTableDialog.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        TableHelper.DeleteTableByNumber(_table.TableNr);
                        TableHelper.SaveTablesToStorage();
                        dialog.dismiss();
                        finish();
                        //MyApplication.GoToHome();
                        //finish();
                        //Intent i = new Intent(context, TablesOverviewActivity.class);                        
                        //startActivity(i);
                        //dialog.dismiss();
                    }
                });
                confirmDeleteTableDialog.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        //
                    }
                });
                confirmDeleteTableDialog.show();
                dialog.dismiss();
            }
        });
        btnExit.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
    }
    //else if(v.getId()==R.id.btnSave)
    ///{
    //   SaveTableOrders();
    //   GotoTableOrderView();
    //finish(); //finish means close. want to refresh tableorder when close this view. so instead use gototableorderview()
    //}   
    //else if(v.getId()==R.id.btnAllMenu)
    //{
    //   BindingMenuList();
    //}
    else if (v.getId() == R.id.btnMenuGroup) {
        MakeMenuGroupButtons();
    }
    //else if(v.getId()==R.id.btnMenuBar)
    //{
    //   BingMenuBarList();
    //}
    if (v.getId() == R.id.btnCurrentOrders) {
        ShowCurrentOrders();
        //finish();
    } else if (v.getId() == R.id.btnCloseKeyboard) {
        //close soft keyboard
        //http://www.workingfromhere.com/blog/2011/04/27/close-hide-the-android-soft-keyboard/
        InputMethodManager imm = (InputMethodManager) getSystemService(
                MyApplication.getAppContext().INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(editTextInput.getWindowToken(), 0);
        View filling = menusContainer.findViewById(R.id.hint_fill);
        if (filling != null) {
            filling.setVisibility(View.GONE);
        }
        SetEditTextInputText("");
        ShowCurrentOrders();
    }
}

From source file:nf.frex.android.FrexActivity.java

private Dialog createPropertiesDialog() {
    Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.properties_dialog);
    dialog.setTitle(getString(R.string.properties));
    return dialog;
}

From source file:nf.frex.android.FrexActivity.java

private Dialog createDecorationsDialog() {
    Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.decorations_dialog);
    dialog.setTitle(R.string.decorations);
    return dialog;
}

From source file:liqui.droid.activity.Base.java

/**
 * Open about dialog./*  w  w w. j  a v  a2  s  . c  o m*/
 */
public void openAboutDialog() {
    Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.dlg_about);

    try {
        PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        String versionName = packageInfo.versionName;
        dialog.setTitle(getResources().getString(R.string.app_name) + " v" + versionName);
    } catch (PackageManager.NameNotFoundException e) {
        dialog.setTitle(getResources().getString(R.string.app_name));
    }

    Button btnByEmail = (Button) dialog.findViewById(R.id.btn_by_email);
    btnByEmail.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent sendIntent = new Intent(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_EMAIL,
                    new String[] { getResources().getString(R.string.my_email) });
            sendIntent.setType("message/rfc822");
            startActivity(Intent.createChooser(sendIntent, "Select email application."));
        }
    });

    dialog.show();
}

From source file:su.comp.bk.ui.BkEmuActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_COMPUTER_MODEL:
        final CharSequence[] models;
        List<String> modelList = new ArrayList<String>();
        for (Configuration model : Configuration.values()) {
            int modelNameId = getResources().getIdentifier(model.name().toLowerCase(), "string",
                    getPackageName());/*from   w ww .j  a va  2  s  . c o m*/
            modelList.add((modelNameId != 0) ? getString(modelNameId) : model.name());
        }
        models = modelList.toArray(new String[modelList.size()]);
        return new AlertDialog.Builder(this).setTitle(R.string.menu_select_model).setSingleChoiceItems(models,
                getComputerConfiguration().ordinal(), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // Mark selected item by tag
                        ListView listView = ((AlertDialog) dialog).getListView();
                        listView.setTag(Integer.valueOf(which));
                    }
                }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        // Get tagged selected item, if any
                        ListView listView = ((AlertDialog) dialog).getListView();
                        Integer selected = (Integer) listView.getTag();
                        if (selected != null) {
                            Configuration config = Configuration.values()[selected];
                            if (computer.getConfiguration() != config) {
                                // Set new computer configuration and restart activity
                                setComputerConfiguration(config);
                                restartActivity(null);
                            }
                        }
                    }
                }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        // Do nothing on cancel
                    }
                }).create();
    case DIALOG_ABOUT:
        Dialog aboutDialog = new Dialog(this);
        aboutDialog.setTitle(R.string.menu_about);
        aboutDialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
        aboutDialog.setContentView(R.layout.about_dialog);
        aboutDialog.getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
                android.R.drawable.ic_dialog_info);
        TextView versionTextView = (TextView) aboutDialog.findViewById(R.id.about_version);
        try {
            versionTextView.setText(getResources().getString(R.string.about_version,
                    getPackageManager().getPackageInfo(getPackageName(), 0).versionName));
        } catch (NameNotFoundException e) {
        }
        return aboutDialog;
    case DIALOG_DISK_MANAGER:
        Dialog fddManagerDialog = new Dialog(this);
        fddManagerDialog.setTitle(R.string.menu_disk_manager);
        fddManagerDialog.setContentView(R.layout.fdd_mgr_dialog);
        return fddManagerDialog;
    case DIALOG_DISK_MOUNT_ERROR:
        return new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.err)
                .setMessage(R.string.dialog_disk_mount_error).setPositiveButton(R.string.ok, null).create();
    }
    return null;
}