Java Code Examples for android.widget.EditText#setSingleLine()

The following examples show how to use android.widget.EditText#setSingleLine() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityMain.java    From nfcspy with GNU General Public License v3.0 6 votes vote down vote up
private void setDiscoveryDelay() {

		final EditText input = new EditText(this);
		input.setHint(this.getString(R.string.hint_discoverydelay));
		input.setText(Integer.toString(nfc.getDiscoveryDelay()));
		input.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
		input.setKeyListener(DigitsKeyListener.getInstance("01234567890"));
		input.setSingleLine(true);

		SetDelayHelper helper = new SetDelayHelper(nfc, input);

		new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT)
				.setTitle(R.string.action_discoverydelay)
				.setMessage(R.string.lab_discoverydelay).setView(input)
				.setPositiveButton(R.string.action_ok, helper)
				.setNegativeButton(R.string.action_cancel, helper).show();
	}
 
Example 2
Source File: MainActivity.java    From Leisure with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void showSearchDialog(){
    final EditText editText = new EditText(this);
    editText.setGravity(Gravity.CENTER);
    editText.setSingleLine();
    new AlertDialog.Builder(this)
            .setTitle(getString(R.string.text_search_books))
            .setIcon(R.mipmap.ic_search)
            .setView(editText)
            .setPositiveButton(getString(R.string.text_ok), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if(Utils.hasString(editText.getText().toString())){
                        Intent intent = new Intent(MainActivity.this,SearchBooksActivity.class);
                        Bundle bundle = new Bundle();
                        bundle.putString(getString(R.string.id_search_text),editText.getText().toString());
                        intent.putExtras(bundle);
                        startActivity(intent);
                    }
                }
            }).show();
}
 
Example 3
Source File: APDE.java    From APDE with GNU General Public License v2.0 6 votes vote down vote up
public EditText createAlertDialogEditText(Activity context, AlertDialog.Builder builder, String content, boolean selectAll) {
	final EditText input = new EditText(context);
	input.setSingleLine();
	input.setText(content);
	if (selectAll) {
		input.selectAll();
	}
	
	// http://stackoverflow.com/a/27776276/
	FrameLayout frameLayout = new FrameLayout(context);
	FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
	
	// http://stackoverflow.com/a/35211225/
	float dpi = getResources().getDisplayMetrics().density;
	params.leftMargin = (int) (19 * dpi);
	params.topMargin = (int) (5 * dpi);
	params.rightMargin = (int) (14 * dpi);
	params.bottomMargin = (int) (5 * dpi);
	
	frameLayout.addView(input, params);
	
	builder.setView(frameLayout);
	
	return input;
}
 
Example 4
Source File: FavoriteDialogs.java    From MCPDict with MIT License 6 votes vote down vote up
public static void add(final char unicode) {
    final EditText editText = new EditText(activity);
    editText.setHint(R.string.favorite_add_hint);
    editText.setSingleLine(false);
    new AlertDialog.Builder(activity)
        .setIcon(R.drawable.ic_star_yellow)
        .setTitle(String.format(activity.getString(R.string.favorite_add), unicode))
        .setView(editText)
        .setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String comment = editText.getText().toString();
                UserDatabase.insertFavorite(unicode, comment);
                String message = String.format(activity.getString(R.string.favorite_add_done), unicode);
                Boast.showText(activity, message, Toast.LENGTH_SHORT);
                FavoriteFragment fragment = activity.getFavoriteFragment();
                if (fragment != null) {
                    fragment.notifyAddItem();
                }
                activity.getCurrentFragment().refresh();
            }
        })
        .setNegativeButton(R.string.cancel, null)
        .show();
}
 
Example 5
Source File: CompassFragment.java    From TextFiction with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onLongClick(View v) {
	editCommand = new EditText(getActivity());
	editCommand.setSingleLine(true);
	try {
		editCommand.setText(v.getTag().toString());
		editCommand.setTag(v);
	}
	catch (Exception e) {
		Log.w(getClass().getName(), e); // ?!
	}
	AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
	builder.setView(editCommand);
	builder.setTitle(R.string.title_edit_direction);
	builder.setPositiveButton(android.R.string.ok, this);
	builder.show();
	return true;
}
 
Example 6
Source File: RecentActivityController.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
@ActionMethod(ids = R.id.bookmenu_rename)
public void renameBook(final ActionEx action) {
    final BookNode book = action.getParameter("source");
    if (book == null) {
        return;
    }

    final FileUtils.FilePath file = FileUtils.parseFilePath(book.path, CodecType.getAllExtensions());
    final EditText input = new AppCompatEditText(getManagedComponent());
    input.setSingleLine();
    input.setText(file.name);
    input.selectAll();

    final ActionDialogBuilder builder = new ActionDialogBuilder(getContext(), this);
    builder.setTitle(R.string.book_rename_title);
    builder.setMessage(R.string.book_rename_msg);
    builder.setView(input);
    builder.setPositiveButton(R.id.actions_doRenameBook, new Constant("source", book), new Constant("file", file),
            new EditableValue("input", input));
    builder.setNegativeButton().show();
}
 
Example 7
Source File: EditTextSettingsCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public EditTextSettingsCell(Context context) {
    super(context);

    textView = new EditText(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    textView.setBackgroundDrawable(null);
    textView.setPadding(0, 0, 0, 0);
    textView.setInputType(textView.getInputType() |EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0));
}
 
Example 8
Source File: BrowserActivityController.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
@ActionMethod(ids = R.id.bookmenu_rename)
public void renameBook(final ActionEx action) {
    final File file = action.getParameter("source");
    if (file == null) {
        return;
    }

    final FileUtils.FilePath path = FileUtils.parseFilePath(file.getAbsolutePath(), CodecType.getAllExtensions());
    final EditText input = new AppCompatEditText(getManagedComponent());
    input.setSingleLine();
    input.setText(path.name);
    input.selectAll();

    final ActionDialogBuilder builder = new ActionDialogBuilder(this.getManagedComponent(), this);
    builder.setTitle(R.string.book_rename_title);
    builder.setMessage(R.string.book_rename_msg);
    builder.setView(input);
    builder.setPositiveButton(R.id.actions_doRenameBook, new Constant("source", file), new Constant("file", path),
            new EditableValue("input", input));
    builder.setNegativeButton().show();
}
 
Example 9
Source File: DialogHelper.java    From Onosendai with Apache License 2.0 6 votes vote down vote up
public static void askString (final Context context, final String msg,
		final String oldValue, final boolean multiLine, final boolean spellCheck,
		final Listener<String> onString) {
	final AlertDialog.Builder dlgBld = new AlertDialog.Builder(context);
	dlgBld.setMessage(msg);
	final EditText editText = new EditText(context);
	editText.setSelectAllOnFocus(true);
	if (oldValue != null) editText.setText(oldValue);
	if (!multiLine) editText.setSingleLine();
	if (!spellCheck) editText.setInputType(editText.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
	editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
	dlgBld.setView(editText);
	dlgBld.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
		@Override
		public void onClick (final DialogInterface dialog, final int which) {
			dialog.dismiss();
			onString.onAnswer(editText.getText().toString().trim());
		}
	});
	dlgBld.setNegativeButton(android.R.string.cancel, DLG_CANCEL_CLICK_LISTENER);
	dlgBld.show();
}
 
Example 10
Source File: MLAlertDialog.java    From NewXmPluginSDK with Apache License 2.0 6 votes vote down vote up
/**
 * 该方法不能与setView()方法同时使用
 * 
 * @return
 */
public Builder setInputView(String str, boolean singleLine) {
    View view = View.inflate(mContext, R.layout.ml_alert_dialog_input_view, null);
    setView(view,
            mContext.getResources().getDimensionPixelSize(
                    R.dimen.alertdialog_button_panel_padding_horizontal),
            0,
            mContext.getResources().getDimensionPixelSize(
                    R.dimen.alertdialog_button_panel_padding_horizontal),
            mContext.getResources().getDimensionPixelSize(
                    R.dimen.alertdialog_custom_panel_padding_bottom));
    EditText et = ((EditText) view.findViewById(R.id.input_text));
    et.setSingleLine(singleLine);
    if (!TextUtils.isEmpty(str))
        et.setHint(str);
    et.requestFocus();
    return this;
}
 
Example 11
Source File: NativeElementView.java    From htmlview with Apache License 2.0 5 votes vote down vote up
static NativeElementView createTextArea(final Context context, final Element element) {
  int textSize = element.getScaledPx(Style.FONT_SIZE);
  EditText editText = new EditText(context);
  editText.setSingleLine(false);
  editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
  editText.setGravity(Gravity.TOP);
  // TODO: Calculate lines based on height if fixed.
  editText.setLines(element.getAttributeInt("rows", 2));
  editText.setVerticalScrollBarEnabled(true);
  LayoutParams params = new LayoutParams(0, LayoutParams.WRAP_CONTENT);
  editText.setLayoutParams(params);
  NativeElementView result = new NativeElementView(context, element, false, editText);
  result.reset();
  return result;
}
 
Example 12
Source File: DialogHelper.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public static void initFilenameInputDialog(MaterialDialog show) {
    final EditText editText = show.getInputEditText();
    editText.setSingleLine();
    editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);

    // create an initial filename to suggest to the user
    String filename = createLogFilename();
    editText.setText(filename);

    // highlight everything but the .txt at the end
    editText.setSelection(0, filename.length() - 4);
}
 
Example 13
Source File: RenameFileDialog.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
@NonNull
   @Override
public Dialog onCreateDialog(Bundle savedInstanceState) 
{		
	AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
	alert.setMessage(getString(R.string.enter_new_file_name));

	// Set an EditText view to get user input
	final String filename = getArguments().getString(ARG_FILENAME);
	final EditText input = new EditText(getActivity());
	input.setId(android.R.id.edit);
	input.setSingleLine();
	input.setText(filename);
	StringPathUtil spu = new StringPathUtil(filename);
	String fnWoExt = spu.getFileNameWithoutExtension();
	if(fnWoExt.length() > 0)
		input.setSelection(0, fnWoExt.length());
	alert.setView(input);

	alert.setPositiveButton(getString(android.R.string.ok),
			(dialog, whichButton) -> renameFile(input.getText().toString()));

	alert.setNegativeButton(android.R.string.cancel,
			(dialog, whichButton) ->
			{
                   // Canceled.
               });

	return alert.create();
}
 
Example 14
Source File: DialogHelper.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
public static void initFilenameInputDialog(MaterialDialog show) {
    final EditText editText = show.getInputEditText();
    editText.setSingleLine();
    editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);

    // create an initial filename to suggest to the user
    String filename = createLogFilename();
    editText.setText(filename);

    // highlight everything but the .txt at the end
    editText.setSelection(0, filename.length() - 4);
}
 
Example 15
Source File: CarTableDataAdapter.java    From SortableTableView with Apache License 2.0 5 votes vote down vote up
private View renderEditableCatName(final Car car) {
    final EditText editText = new EditText(getContext());
    editText.setText(car.getName());
    editText.setPadding(20, 10, 20, 10);
    editText.setTextSize(TEXT_SIZE);
    editText.setSingleLine();
    editText.addTextChangedListener(new CarNameUpdater(car));
    return editText;
}
 
Example 16
Source File: ViewerActivityController.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
public void askPassword(final String fileName, final int promtId) {
    final EditText input = new AppCompatEditText(getManagedComponent());
    input.setSingleLine(true);
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

    final ActionDialogBuilder builder = new ActionDialogBuilder(getManagedComponent(), this);
    builder.setTitle(fileName).setMessage(promtId).setView(input);
    builder.setPositiveButton(R.id.actions_redecodingWithPassword, new EditableValue("input", input));
    builder.setNegativeButton(R.id.mainmenu_close).show();
}
 
Example 17
Source File: AutofillProfileEditor.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void resetFormFields(int countryCodeIndex, boolean autoFocusFirstField) {
    // Save field text so we can restore it after updating the fields for the current country,
    // and reset mAddressFields.
    String[] fieldText = new String[mAddressFields.length];
    for (int i = 0; i < mAddressFields.length; i++) {
        if (mAddressFields[i] != null) {
            fieldText[i] = mAddressFields[i].getEditText().getText().toString();
            mAddressFields[i] = null;
        }
    }

    // Remove all address form fields.
    mWidgetRoot.removeAllViews();

    // Get address fields for the selected country.
    List<AddressUiComponent> fields = mAutofillProfileBridge.getAddressUiComponents(
            mCountryCodes.get(countryCodeIndex),
            mLanguageCodeString);
    if (!mUseSavedProfileLanguage) {
        mLanguageCodeString = mAutofillProfileBridge.getCurrentBestLanguageCode();
    }

    // Create form fields and focus the first field if autoFocusFirstField is true.
    boolean firstField = true;
    for (AddressUiComponent field : fields) {
        CompatibilityTextInputLayout fieldFloatLabel =
                (CompatibilityTextInputLayout) mInflater.inflate(
                        R.layout.preference_address_float_label_layout, mWidgetRoot, false);
        fieldFloatLabel.setHint(field.label);

        EditText fieldEditText = fieldFloatLabel.getEditText();
        fieldEditText.addTextChangedListener(this);
        if (field.id == AddressField.STREET_ADDRESS) {
            fieldEditText.setSingleLine(false);
        }

        mAddressFields[field.id] = fieldFloatLabel;
        mWidgetRoot.addView(fieldFloatLabel);

        if (firstField && autoFocusFirstField) {
            fieldEditText.requestFocus();
            firstField = false;
        }
    }

    // Add back saved field text.
    for (int i = 0; i < mAddressFields.length; i++) {
        if (mAddressFields[i] != null && fieldText[i] != null
                && !TextUtils.isEmpty(fieldText[i])) {
            mAddressFields[i].getEditText().setText(fieldText[i]);
        }
    }
}
 
Example 18
Source File: AutofillProfileEditor.java    From delion with Apache License 2.0 4 votes vote down vote up
private void resetFormFields(int countryCodeIndex, boolean autoFocusFirstField) {
    // Save field text so we can restore it after updating the fields for the current country,
    // and reset mAddressFields.
    String[] fieldText = new String[mAddressFields.length];
    for (int i = 0; i < mAddressFields.length; i++) {
        if (mAddressFields[i] != null) {
            fieldText[i] = mAddressFields[i].getEditText().getText().toString();
            mAddressFields[i] = null;
        }
    }

    // Remove all address form fields.
    mWidgetRoot.removeAllViews();

    // Get address fields for the selected country.
    List<AddressUiComponent> fields = mAutofillProfileBridge.getAddressUiComponents(
            mCountryCodes.get(countryCodeIndex),
            mLanguageCodeString);
    if (!mUseSavedProfileLanguage) {
        mLanguageCodeString = mAutofillProfileBridge.getCurrentBestLanguageCode();
    }

    // Create form fields and focus the first field if autoFocusFirstField is true.
    boolean firstField = true;
    for (AddressUiComponent field : fields) {
        CompatibilityTextInputLayout fieldFloatLabel =
                (CompatibilityTextInputLayout) mInflater.inflate(
                        R.layout.preference_address_float_label_layout, mWidgetRoot, false);
        fieldFloatLabel.setHint(field.label);

        EditText fieldEditText = fieldFloatLabel.getEditText();
        fieldEditText.setContentDescription(field.label);
        fieldEditText.addTextChangedListener(this);
        if (field.id == AddressField.STREET_ADDRESS) {
            fieldEditText.setSingleLine(false);
        }

        mAddressFields[field.id] = fieldFloatLabel;
        mWidgetRoot.addView(fieldFloatLabel);

        if (firstField && autoFocusFirstField) {
            fieldEditText.requestFocus();
            firstField = false;
        }
    }

    // Add back saved field text.
    for (int i = 0; i < mAddressFields.length; i++) {
        if (mAddressFields[i] != null && fieldText[i] != null
                && !TextUtils.isEmpty(fieldText[i])) {
            mAddressFields[i].getEditText().setText(fieldText[i]);
        }
    }
}
 
Example 19
Source File: AlgDialog.java    From TwistyTimer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onClick(View view) {
    final DatabaseHandler dbHandler = TwistyTimer.getDBHandler();

    switch (view.getId()) {
        case R.id.editButton:
            MaterialDialog dialog = ThemeUtils.roundDialog(mContext, new MaterialDialog.Builder(mContext)
                    .title(R.string.edit_algorithm)
                    .input("", algorithm.getAlgs(), (dialog1, input) -> {
                        algorithm.setAlgs(input.toString());
                        dbHandler.updateAlgorithmAlg(mId, input.toString());
                        algText.setText(input.toString());
                        updateList();
                    })
                    .inputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE)
                    .positiveText(R.string.action_done)
                    .negativeText(R.string.action_cancel)
                    .build());
            EditText editText = dialog.getInputEditText();
            if (editText != null) {
                editText.setSingleLine(false);
                editText.setLines(5);
                editText.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
                editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
            }
            dialog.show();
            break;

        case R.id.progressButton:
            final AppCompatSeekBar seekBar = (AppCompatSeekBar) LayoutInflater.from(mContext).inflate(R.layout.dialog_progress, null);
            seekBar.setProgress(algorithm.getProgress());
            ThemeUtils.roundAndShowDialog(mContext, new MaterialDialog.Builder(mContext)
                    .title(R.string.dialog_set_progress)
                    .customView(seekBar, false)
                    .positiveText(R.string.action_update)
                    .negativeText(R.string.action_cancel)
                    .onPositive((dialog12, which) -> {
                        int seekProgress = seekBar.getProgress();
                        algorithm.setProgress(seekProgress);
                        dbHandler.updateAlgorithmProgress(mId, seekProgress);
                        progressBar.setProgress(seekProgress);
                        updateList();
                    })
                    .build());
            break;

        case R.id.revertButton:
            ThemeUtils.roundAndShowDialog(mContext, new MaterialDialog.Builder(mContext)
                    .title(R.string.dialog_revert_title_confirmation)
                    .content(R.string.dialog_revert_content_confirmation)
                    .positiveText(R.string.action_reset)
                    .negativeText(R.string.action_cancel)
                    .onPositive((dialog13, which) -> {
                        algorithm.setAlgs(AlgUtils.getDefaultAlgs(algorithm.getSubset(), algorithm.getName()));
                        dbHandler.updateAlgorithmAlg(mId, algorithm.getAlgs());
                        algText.setText(algorithm.getAlgs());
                    })
                    .build());
            break;
    }
}
 
Example 20
Source File: PlaylistDialog.java    From mobile-manager-tool with MIT License 4 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {

    super.onCreate(icicle);
    setContentView(new LinearLayout(this));

    action = getIntent().getAction();

    mRenameId = icicle != null ? icicle.getLong(INTENT_KEY_RENAME) : getIntent().getLongExtra(
            INTENT_KEY_RENAME, -1);
    mList = icicle != null ? icicle.getLongArray(INTENT_PLAYLIST_LIST) : getIntent()
            .getLongArrayExtra(INTENT_PLAYLIST_LIST);
    if (INTENT_RENAME_PLAYLIST.equals(action)) {
        mOriginalName = nameForId(mRenameId);
        mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME)
                : mOriginalName;
    } else if (INTENT_CREATE_PLAYLIST.equals(action)) {
        mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME)
                : makePlaylistName();
        mOriginalName = mDefaultName;
    }

    DisplayMetrics dm = new DisplayMetrics();
    dm = getResources().getDisplayMetrics();

    mPlaylistDialog = new AlertDialog.Builder(this).create();
    mPlaylistDialog.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    if (action != null && mRenameId >= 0 && mOriginalName != null || mDefaultName != null) {

        mPlaylist = new EditText(this);
        mPlaylist.setSingleLine(true);
        mPlaylist.setText(mDefaultName);
        mPlaylist.setSelection(mDefaultName.length());
        mPlaylist.addTextChangedListener(this);

        mPlaylistDialog.setIcon(android.R.drawable.ic_dialog_info);
        String promptformat;
        String prompt = "";
        if (INTENT_RENAME_PLAYLIST.equals(action)) {
            promptformat = getString(R.string.rename_playlist);
            prompt = String.format(promptformat, mOriginalName, mDefaultName);
        } else if (INTENT_CREATE_PLAYLIST.equals(action)) {
            promptformat = getString(R.string.new_playlist);
            prompt = String.format(promptformat, mDefaultName);
        }

        mPlaylistDialog.setTitle(prompt);
        mPlaylistDialog.setView(mPlaylist, (int)(8 * dm.density), (int)(8 * dm.density),
                (int)(8 * dm.density), (int)(4 * dm.density));
        if (INTENT_RENAME_PLAYLIST.equals(action)) {
            mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save),
                    mRenamePlaylistListener);
            mPlaylistDialog.setOnShowListener(this);
        } else if (INTENT_CREATE_PLAYLIST.equals(action)) {
            mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save),
                    mCreatePlaylistListener);
        }
        mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
                new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        finish();
                    }
                });
        mPlaylistDialog.setOnCancelListener(this);
        mPlaylistDialog.show();
    } else {
        Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show();
        finish();
    }

}