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:de.bogutzky.psychophysiocollector.app.MainActivity.java

private void showSettings() {
    final SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
    int selfReportIntervalSpinnerPosition = sharedPref.getInt("selfReportIntervalSpinnerPosition", 2);
    int selfReportVarianceSpinnerPosition = sharedPref.getInt("selfReportVarianceSpinnerPosition", 0);
    int questionnaireSpinnerPosition = sharedPref.getInt("questionnaireSpinnerPosition", 0);
    //int baselineQuestionnaireSpinnerPosition = sharedPref.getInt("baselineQuestionnaireSpinnerPosition", 0);
    String activityName = sharedPref.getString("activityName", "");
    String participantFirstName = sharedPref.getString("participantFirstName", "");
    String participantLastName = sharedPref.getString("participantLastName", "");
    boolean configureInterval = sharedPref.getBoolean("configureInterval", false);
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.settings);
    dialog.setTitle(getString(R.string.action_settings));
    dialog.setCancelable(true);//ww w .  j  a  va 2s  . co  m
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.height = WindowManager.LayoutParams.MATCH_PARENT;
    dialog.getWindow().setAttributes(lp);
    selfReportIntervalSpinner = (Spinner) dialog.findViewById(R.id.self_report_interval_spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.study_protocol_settings_self_report_interval_values, android.R.layout.simple_spinner_item);
    selfReportIntervalSpinner.setAdapter(adapter);
    selfReportIntervalSpinner.setSelection(selfReportIntervalSpinnerPosition);
    selfReportVarianceSpinner = (Spinner) dialog.findViewById(R.id.self_report_variance_spinner);
    ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(this,
            R.array.study_protocol_settings_self_report_variance_values, android.R.layout.simple_spinner_item);
    selfReportVarianceSpinner.setAdapter(adapter2);
    selfReportVarianceSpinner.setSelection(selfReportVarianceSpinnerPosition);

    questionnaireSpinner = (Spinner) dialog.findViewById(R.id.questionnaireSpinner);
    //baselineQuestionnaireSpinner = (Spinner) dialog.findViewById(R.id.baseline_questionnaireSpinner);

    String[] questionnaireTitles = new String[0];
    try {
        questionnaireTitles = new String[questionnaireCount];
        for (int i = 0; i < questionnaireCount; i++) {
            String questionnaireFilename = questionnaireFilenames[i];
            String questionnairePath = "questionnaires/" + localeString + "/" + questionnaireFilename;
            try {
                JSONObject questionnaire = Utils
                        .getJSONObjectFromInputStream(getAssets().open(questionnairePath));
                String questionnaireTitle = questionnaire.getJSONObject("questionnaire").getString("title");
                questionnaireTitles[i] = questionnaireTitle;
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    ArrayAdapter<String> qSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
            questionnaireTitles);
    questionnaireSpinner.setAdapter(qSpinnerAdapter);
    questionnaireSpinner.setSelection(questionnaireSpinnerPosition);
    //baselineQuestionnaireSpinner.setAdapter(qSpinnerAdapter);
    //baselineQuestionnaireSpinner.setSelection(baselineQuestionnaireSpinnerPosition);

    final EditText participantFirstNameEditText = (EditText) dialog
            .findViewById(R.id.participant_first_name_edit_text);
    final EditText participantLastNameEditText = (EditText) dialog
            .findViewById(R.id.participant_last_name_edit_text);
    final EditText activityNameEditText = (EditText) dialog.findViewById(R.id.activity_name_edit_text);
    participantFirstNameEditText.setText(participantFirstName);
    participantLastNameEditText.setText(participantLastName);
    activityNameEditText.setText(activityName);

    final Switch configureIntervalSwitch = (Switch) dialog.findViewById(R.id.configure_interval_switch);
    configureIntervalSwitch.setChecked(configureInterval);
    if (configureInterval) {
        dialog.findViewById(R.id.configure_interval_layout).setVisibility(View.VISIBLE);
        dialog.findViewById(R.id.configure_variance_layout).setVisibility(View.VISIBLE);
    } else {
        dialog.findViewById(R.id.configure_interval_layout).setVisibility(View.GONE);
        dialog.findViewById(R.id.configure_variance_layout).setVisibility(View.GONE);
    }

    Button saveButton = (Button) dialog.findViewById(R.id.saveButton);
    saveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            selfReportInterval = Integer.valueOf(selfReportIntervalSpinner.getSelectedItem().toString());
            selfReportVariance = Integer.valueOf(selfReportVarianceSpinner.getSelectedItem().toString());

            MainActivity.this.participantFirstName = participantFirstNameEditText.getText().toString().trim();
            MainActivity.this.participantLastName = participantLastNameEditText.getText().toString().trim();
            MainActivity.this.activityName = activityNameEditText.getText().toString().trim();
            MainActivity.this.intervalConfigured = configureIntervalSwitch.isChecked();

            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("selfReportIntervalSpinnerPosition",
                    selfReportIntervalSpinner.getSelectedItemPosition());
            editor.putInt("selfReportVarianceSpinnerPosition",
                    selfReportVarianceSpinner.getSelectedItemPosition());
            editor.putInt("questionnaireSpinnerPosition", questionnaireSpinner.getSelectedItemPosition());
            //editor.putInt("baselineQuestionnaireSpinnerPosition", baselineQuestionnaireSpinner.getSelectedItemPosition());
            editor.putInt("selfReportInterval",
                    Integer.valueOf(selfReportIntervalSpinner.getSelectedItem().toString()));
            editor.putInt("selfReportVariance",
                    Integer.valueOf(selfReportVarianceSpinner.getSelectedItem().toString()));

            editor.putString("participantFirstName", participantFirstNameEditText.getText().toString().trim());
            editor.putString("participantLastName", participantLastNameEditText.getText().toString().trim());
            editor.putString("activityName", activityNameEditText.getText().toString().trim());
            editor.putBoolean("configureInterval", configureIntervalSwitch.isChecked());
            editor.apply();

            dialog.dismiss();
        }
    });

    configureIntervalSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                dialog.findViewById(R.id.configure_interval_layout).setVisibility(View.VISIBLE);
                dialog.findViewById(R.id.configure_variance_layout).setVisibility(View.VISIBLE);
            } else {
                dialog.findViewById(R.id.configure_interval_layout).setVisibility(View.GONE);
                dialog.findViewById(R.id.configure_variance_layout).setVisibility(View.GONE);
            }
        }
    });
    dialog.show();
}

From source file:net.reichholf.dreamdroid.activities.TimerEditActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final Dialog dialog;

    Calendar cal;/*from ww w. j  a  v  a  2s  . c  om*/
    Button buttonApply;

    applyViewValues();

    switch (id) {

    case (DIALOG_PICK_BEGIN_ID):
        cal = getCalendarFromTimestamp(mTimer.getString("begin"));

        dialog = new Dialog(this);
        dialog.setContentView(R.layout.date_time_picker);
        dialog.setTitle(R.string.set_time_begin);

        setDateAndTimePicker(dialog, cal);
        dialogRegisterCancel(dialog);

        buttonApply = (Button) dialog.findViewById(R.id.ButtonApply);
        buttonApply.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onTimerBeginSet(getCalendarFromPicker(dialog));
            }
        });

        dialog.show();
        break;

    case (DIALOG_PICK_END_ID):
        cal = getCalendarFromTimestamp(mTimer.getString("end"));

        dialog = new Dialog(this);
        dialog.setContentView(R.layout.date_time_picker);
        dialog.setTitle(R.string.set_time_end);

        setDateAndTimePicker(dialog, cal);
        dialogRegisterCancel(dialog);

        buttonApply = (Button) dialog.findViewById(R.id.ButtonApply);
        buttonApply.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onTimerEndSet(getCalendarFromPicker(dialog));
            }
        });

        dialog.show();
        break;

    case (DIALOG_PICK_REPEATED_ID):
        CharSequence[] days = getResources().getTextArray(R.array.weekdays);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getText(R.string.choose_days));
        builder.setMultiChoiceItems(days, mCheckedDays, new OnMultiChoiceClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                mCheckedDays[which] = isChecked;

                String text = setRepeated(mCheckedDays, mTimer);
                mRepeatings.setText(text);

            }

        });
        dialog = builder.create();

        break;

    case (DIALOG_PICK_TAGS_ID):
        CharSequence[] tags = new CharSequence[DreamDroid.TAGS.size()];
        boolean[] selectedTags = new boolean[DreamDroid.TAGS.size()];

        int tc = 0;
        for (String tag : DreamDroid.TAGS) {
            tags[tc] = tag;

            if (mSelectedTags.contains(tag)) {
                selectedTags[tc] = true;
            } else {
                selectedTags[tc] = false;
            }

            tc++;
        }

        mTagsChanged = false;
        mOldTags = new ArrayList<String>();
        mOldTags.addAll(mSelectedTags);

        builder = new AlertDialog.Builder(this);
        builder.setTitle(getText(R.string.choose_tags));

        builder.setMultiChoiceItems(tags, selectedTags, new OnMultiChoiceClickListener() {
            /*
             * (non-Javadoc)
             * 
             * @see android.content.DialogInterface.
             * OnMultiChoiceClickListener
             * #onClick(android.content.DialogInterface, int, boolean)
             */
            @Override
            public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                String tag = DreamDroid.TAGS.get(which);
                mTagsChanged = true;
                if (isChecked) {
                    if (!mSelectedTags.contains(tag)) {
                        mSelectedTags.add(tag);
                    }
                } else {
                    int idx = mSelectedTags.indexOf(tag);
                    if (idx >= 0) {
                        mSelectedTags.remove(idx);
                    }
                }
            }

        });

        builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (mTagsChanged) {
                    // TODO Update current Tags
                    String tags = Tag.implodeTags(mSelectedTags);
                    mTimer.put(Timer.TAGS, tags);
                    mTags.setText(tags);
                }
                dialog.dismiss();
                removeDialog(DIALOG_PICK_TAGS_ID);
            }

        });

        builder.setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                mSelectedTags.clear();
                mSelectedTags.addAll(mOldTags);
                dialog.dismiss();
                removeDialog(DIALOG_PICK_TAGS_ID);
            }

        });

        dialog = builder.create();
        break;
    default:
        dialog = null;
    }

    return dialog;
}

From source file:org.tigase.mobile.TigaseMobileMessengerActivity.java

@Override
protected Dialog onCreateDialog(int id, Bundle bundle) {
    switch (id) {
    case NEWS_DIALOG: {

        String str = bundle.getString("news_html");

        Builder bldr = new AlertDialog.Builder(this);
        bldr.setTitle("News");
        bldr.setCancelable(true);/*  w w w  . j a v a  2 s . c  o  m*/
        bldr.setMessage(Html.fromHtml(str));
        return bldr.create();
    }

    case CONTACT_REMOVE_DIALOG:
        return null;
    case ABOUT_DIALOG: {

        final Dialog dialog = new Dialog(this);
        dialog.setCancelable(true);
        dialog.setCanceledOnTouchOutside(true);

        dialog.setContentView(R.layout.about_dialog);
        dialog.setTitle(getString(R.string.aboutButton));

        TextView tos = (TextView) dialog.findViewById(R.id.aboutTermsOfService);
        tos.setText(Html.fromHtml("<a href='" + getResources().getString(R.string.termsOfServiceURL) + "'>"
                + getResources().getString(R.string.termsOfService) + "</a>"));
        tos.setMovementMethod(LinkMovementMethod.getInstance());

        TextView pp = (TextView) dialog.findViewById(R.id.aboutPrivacyPolicy);
        pp.setText(Html.fromHtml("<a href='" + getResources().getString(R.string.privacyPolicyURL) + "'>"
                + getResources().getString(R.string.privacyPolicy) + "</a>"));
        pp.setMovementMethod(LinkMovementMethod.getInstance());

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

            @Override
            public void onClick(View v) {
                dialog.cancel();
            }
        });
        return dialog;
    }
    default:
        return null;
    }
}

From source file:de.mkrtchyan.recoverytools.RecoveryTools.java

public void showOverRecoveryInstructions() {
    final AlertDialog.Builder Instructions = new AlertDialog.Builder(mContext);
    Instructions.setTitle(R.string.info).setMessage(R.string.flash_over_recovery)
            .setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {
                @Override/*from w  ww .j  a v  a2 s. c o m*/
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        mToolbox.reboot(Toolbox.REBOOT_RECOVERY);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).setNeutralButton(R.string.instructions, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Dialog d = new Dialog(mContext);
                    d.setTitle(R.string.instructions);
                    TextView tv = new TextView(mContext);
                    tv.setTextSize(20);
                    tv.setText(R.string.instruction);
                    d.setContentView(tv);
                    d.setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {
                            Instructions.show();
                        }
                    });
                    d.show();
                }
            }).show();
}

From source file:app.clirnet.com.clirnetapp.activity.LoginActivity.java

private void showCreatePatientAlertDialog() {

    final Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.no_inetrnet_login_dialog);

    dialog.setTitle(
            "Your security credentials have expired. Please login with an active internet connection to refresh.");
    //  dialog.setCancelable(false);

    Button dialogButtonCancel = (Button) dialog.findViewById(R.id.customDialogCancel);
    Button dialogButtonOk = (Button) dialog.findViewById(R.id.customDialogOk);
    // Click cancel to dismiss android custom dialog box
    dialogButtonCancel.setOnClickListener(new View.OnClickListener() {
        @Override/* w w  w.j  a v  a  2 s.c  o m*/
        public void onClick(View v) {

            dialog.dismiss();

        }
    });

    // Your android custom dialog ok action
    // Action for custom dialog ok button click
    dialogButtonOk.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);

            dialog.dismiss();

        }
    });

    dialog.show();

}

From source file:de.mkrtchyan.recoverytools.RecoveryTools.java

public void showFlashHistory(View view) {
    final boolean RecoveryHistory = view.getTag().toString().equals("recovery");
    String PREF_KEY;//  ww w.ja v  a  2s.c o m
    if (RecoveryHistory) {
        PREF_KEY = PREF_KEY_RECOVERY_HISTORY;
    } else {
        PREF_KEY = PREF_KEY_KERNEL_HISTORY;
    }
    final ArrayList<File> HistoryFiles = new ArrayList<File>();
    final ArrayList<String> HistoryFileNames = new ArrayList<String>();
    final Dialog HistoryDialog = new Dialog(mContext);
    HistoryDialog.setTitle(R.string.sHistory);
    ListView HistoryList = new ListView(mContext);
    File tmp;
    for (int i = 0; i < 5; i++) {
        tmp = new File(Common.getStringPref(mContext, PREF_NAME, PREF_KEY + String.valueOf(i)));
        if (!tmp.exists())
            Common.setStringPref(mContext, PREF_NAME, PREF_KEY + String.valueOf(i), "");
        else {
            HistoryFiles.add(tmp);
            HistoryFileNames.add(tmp.getName());
        }
    }
    HistoryList.setAdapter(
            new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1, HistoryFileNames));
    HistoryList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (HistoryFiles.get(arg2).exists()) {
                if (RecoveryHistory) {
                    fRECOVERY = HistoryFiles.get(arg2);
                    rRecoveryFlasher.run();
                } else {
                    fKERNEL = HistoryFiles.get(arg2);
                    rKernelFlasher.run();
                }
                HistoryDialog.dismiss();
            } else {
                Toast.makeText(mContext, R.string.no_choosed, Toast.LENGTH_SHORT).show();
            }
        }
    });
    HistoryDialog.setContentView(HistoryList);
    if (HistoryFileNames.toArray().length > 0) {
        HistoryDialog.show();
    } else {
        Toast.makeText(mContext, R.string.no_history, Toast.LENGTH_SHORT).show();
    }

}

From source file:com.klinker.android.twitter.activities.profile_viewer.ProfilePager.java

public void updateProfile() {
    final Dialog dialog = new Dialog(context);
    dialog.setContentView(R.layout.change_profile_info_dialog);
    dialog.setTitle(getResources().getString(R.string.change_profile_info) + ":");

    final HoloEditText name = (HoloEditText) dialog.findViewById(R.id.name);
    final HoloEditText url = (HoloEditText) dialog.findViewById(R.id.url);
    final HoloEditText location = (HoloEditText) dialog.findViewById(R.id.location);
    final HoloEditText description = (HoloEditText) dialog.findViewById(R.id.description);

    name.setText(thisUser.getName());/* w  ww.  j  av  a 2 s.  c o  m*/

    try {
        url.setText(thisUser.getURLEntity().getDisplayURL());
    } catch (Exception e) {

    }

    location.setText(thisUser.getLocation());
    description.setText(thisUser.getDescription());

    Button cancel = (Button) dialog.findViewById(R.id.cancel);
    cancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    Button change = (Button) dialog.findViewById(R.id.change);
    change.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean ok = true;
            String nameS = null;
            String urlS = null;
            String locationS = null;
            String descriptionS = null;

            if (name.getText().length() <= 20 && ok) {
                if (name.getText().length() > 0) {
                    nameS = name.getText().toString();
                    sharedPrefs.edit()
                            .putString("twitter_users_name_" + sharedPrefs.getInt("current_account", 1), nameS)
                            .commit();
                }
            } else {
                ok = false;
                Toast.makeText(context, getResources().getString(R.string.name_char_length), Toast.LENGTH_SHORT)
                        .show();
            }

            if (url.getText().length() <= 100 && ok) {
                if (url.getText().length() > 0) {
                    urlS = url.getText().toString();
                }
            } else {
                ok = false;
                Toast.makeText(context, getResources().getString(R.string.url_char_length), Toast.LENGTH_SHORT)
                        .show();
            }

            if (location.getText().length() <= 30 && ok) {
                if (location.getText().length() > 0) {
                    locationS = location.getText().toString();
                }
            } else {
                ok = false;
                Toast.makeText(context, getResources().getString(R.string.location_char_length),
                        Toast.LENGTH_SHORT).show();
            }

            if (description.getText().length() <= 160 && ok) {
                if (description.getText().length() > 0) {
                    descriptionS = description.getText().toString();
                }
            } else {
                ok = false;
                Toast.makeText(context, getResources().getString(R.string.description_char_length),
                        Toast.LENGTH_SHORT).show();
            }

            if (ok) {
                new UpdateInfo(nameS, urlS, locationS, descriptionS).execute();
                dialog.dismiss();
            }
        }
    });

    dialog.show();
}

From source file:de.mkrtchyan.recoverytools.RecoveryTools.java

/**
 * Buttons on FlashRecovery and FlashKernel Dialog
 *//*w w  w.  j  av  a  2  s  . c  om*/
public void FlashSupportedRecovery(View view) {
    fRECOVERY = null;
    final File path;
    ArrayList<String> Versions;
    if (!mDevice.downloadUtils(mContext)) {
        /**
         * If there files be needed to flash download it and listing device specified recovery
         * file for example recovery-clockwork-touch-6.0.3.1-grouper.img(read out from IMG_SUMS)
         */
        String SYSTEM = view.getTag().toString();
        if (SYSTEM.equals("clockwork")) {
            Versions = mDevice.getCWMVersions();
            path = PathToCWM;
        } else if (SYSTEM.equals("twrp")) {
            Versions = mDevice.getTWRPVersions();
            path = PathToTWRP;
        } else if (SYSTEM.equals("philz")) {
            Versions = mDevice.getPHILZVersions();
            path = PathToPhilz;
        } else {
            return;
        }

        final Dialog recoveries = new Dialog(mContext);
        recoveries.setTitle(SYSTEM);
        ListView lv = new ListView(mContext);
        recoveries.setContentView(lv);
        lv.setAdapter(new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1, Versions));
        recoveries.show();
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                recoveries.dismiss();
                final String fileName = ((TextView) view).getText().toString();

                if (fileName != null) {
                    fRECOVERY = new File(path, fileName);

                    if (!fRECOVERY.exists()) {
                        Downloader RecoveryDownloader = new Downloader(mContext, RECOVERY_HOST_URL, fRECOVERY,
                                rRecoveryFlasher);
                        RecoveryDownloader.setRetry(true);
                        RecoveryDownloader.setAskBeforeDownload(true);
                        RecoveryDownloader.setChecksumFile(RecoveryCollectionFile);
                        RecoveryDownloader.ask();
                    } else {
                        rRecoveryFlasher.run();
                    }
                }
            }
        });
    }
}

From source file:net.momodalo.app.vimtouch.VimTouch.java

public void showCmdHistory() {

    final Dialog dialog = new Dialog(this, R.style.DialogSlideAnim);

    // Setting dialogview
    Window window = dialog.getWindow();
    window.setGravity(Gravity.BOTTOM);/*from   w w  w  .  ja v  a2s  . co m*/

    window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    dialog.setTitle(null);
    dialog.setContentView(R.layout.hist_list);
    dialog.setCancelable(true);

    LinearLayout layout = (LinearLayout) dialog.findViewById(R.id.hist_layout);
    if (AndroidCompat.SDK >= 11) {
        layout.setShowDividers(LinearLayout.SHOW_DIVIDER_BEGINNING | LinearLayout.SHOW_DIVIDER_MIDDLE
                | LinearLayout.SHOW_DIVIDER_END);
    }
    LayoutParams params = layout.getLayoutParams();
    params.width = mScreenWidth;
    layout.setLayoutParams(params);

    LayoutInflater inflater = LayoutInflater.from(this);
    boolean exists = false;

    for (int i = 1; i <= 10; i++) {
        TextView button = (TextView) inflater.inflate(R.layout.histbutton, layout, false);
        String cmd = Exec.getCmdHistory(i);
        if (cmd.length() == 0)
            break;
        exists = true;
        button.setText(":" + cmd);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                TextView text = (TextView) v;
                CharSequence cmd = text.getText();
                Exec.doCommand(cmd.subSequence(1, cmd.length()).toString());
                dialog.dismiss();
            }
        });
        layout.addView((View) button);
    }

    if (exists)
        dialog.show();
}

From source file:com.klinker.android.twitter.ui.profile_viewer.ProfilePager.java

public void updateProfile() {
    final Dialog dialog = new Dialog(context);
    dialog.setContentView(R.layout.change_profile_info_dialog);
    dialog.setTitle(getResources().getString(R.string.change_profile_info) + ":");

    final HoloEditText name = (HoloEditText) dialog.findViewById(R.id.name);
    final HoloEditText url = (HoloEditText) dialog.findViewById(R.id.url);
    final HoloEditText location = (HoloEditText) dialog.findViewById(R.id.location);
    final HoloEditText description = (HoloEditText) dialog.findViewById(R.id.description);

    Button cancel = (Button) dialog.findViewById(R.id.cancel);
    cancel.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w ww.jav a 2 s.  c o  m*/
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    Button change = (Button) dialog.findViewById(R.id.change);
    change.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean ok = true;
            String nameS = null;
            String urlS = null;
            String locationS = null;
            String descriptionS = null;

            if (name.getText().length() <= 20 && ok) {
                if (name.getText().length() > 0) {
                    nameS = name.getText().toString();
                    sharedPrefs.edit()
                            .putString("twitter_users_name_" + sharedPrefs.getInt("current_account", 1), nameS)
                            .commit();
                }
            } else {
                ok = false;
                Toast.makeText(context, getResources().getString(R.string.name_char_length), Toast.LENGTH_SHORT)
                        .show();
            }

            if (url.getText().length() <= 100 && ok) {
                if (url.getText().length() > 0) {
                    urlS = url.getText().toString();
                }
            } else {
                ok = false;
                Toast.makeText(context, getResources().getString(R.string.url_char_length), Toast.LENGTH_SHORT)
                        .show();
            }

            if (location.getText().length() <= 30 && ok) {
                if (location.getText().length() > 0) {
                    locationS = location.getText().toString();
                }
            } else {
                ok = false;
                Toast.makeText(context, getResources().getString(R.string.location_char_length),
                        Toast.LENGTH_SHORT).show();
            }

            if (description.getText().length() <= 160 && ok) {
                if (description.getText().length() > 0) {
                    descriptionS = description.getText().toString();
                }
            } else {
                ok = false;
                Toast.makeText(context, getResources().getString(R.string.description_char_length),
                        Toast.LENGTH_SHORT).show();
            }

            if (ok) {
                new UpdateInfo(nameS, urlS, locationS, descriptionS).execute();
                dialog.dismiss();
            }
        }
    });

    dialog.show();
}