Example usage for android.widget EditText EditText

List of usage examples for android.widget EditText EditText

Introduction

In this page you can find the example usage for android.widget EditText EditText.

Prototype

public EditText(Context context) 

Source Link

Usage

From source file:com.dish.browser.activity.BrowserActivity.java

/**
 * method that shows a dialog asking what string the user wishes to search
 * for. It highlights the text entered.//  ww w  .j a v  a  2  s.co m
 */
private void findInPage() {
    final AlertDialog.Builder finder = new AlertDialog.Builder(mActivity);
    finder.setTitle(getResources().getString(R.string.action_find));
    final EditText getHome = new EditText(this);
    getHome.setHint(getResources().getString(R.string.search_hint));
    finder.setView(getHome);
    finder.setPositiveButton(getResources().getString(R.string.search_hint),
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String query = getHome.getText().toString();
                    if (query.length() > 0)
                        showSearchInterfaceBar(query);
                }
            });
    finder.show();
}

From source file:com.doplgangr.secrecy.views.FilesListFragment.java

void renameSelectedItems() {
    for (final Integer index : mAdapter.getSelected()) {
        decryptCounter++;/*from ww  w.j a va2s.c  o m*/
        if (mAdapter.hasIndex(index)) {
            if (attached) {
                final EditText renameView = new EditText(context);
                renameView.setText(mAdapter.getItem(index).getDecryptedFileName());

                new AlertDialog.Builder(context).setTitle(getString(R.string.File__rename)).setView(renameView)
                        .setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                String newName = renameView.getText().toString();

                                try {
                                    mAdapter.getItem(index).rename(newName);
                                } catch (SecrecyCipherStreamException e) {
                                    e.printStackTrace();
                                } catch (FileNotFoundException e) {
                                    e.printStackTrace();
                                }

                                mAdapter.notifyItemChanged(index);
                            }
                        }).setNegativeButton(R.string.CANCEL, Util.emptyClickListener).show();
            }
        }
    }
}

From source file:com.eveningoutpost.dexdrip.Home.java

private void promptTextInput_old() {

    if (recognitionRunning)
        return;/*from   w w w. j  a  v a 2s  . c  o  m*/
    recognitionRunning = true;

    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Type treatment\neg: units x.x");
    // Set up the input
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    builder.setView(input);
    // Set up the buttons
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            voiceRecognitionText.setText(input.getText().toString());
            voiceRecognitionText.setVisibility(View.VISIBLE);
            last_speech_time = JoH.ts();
            naturalLanguageRecognition(input.getText().toString());

        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    final AlertDialog dialog = builder.create();
    input.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                if (dialog != null)
                    dialog.getWindow()
                            .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }
        }
    });
    dialog.show();
    recognitionRunning = false;
}

From source file:in.andres.kandroid.ui.TaskDetailActivity.java

private void showCommentDialog(@Nullable final KanboardComment comment) {
    AlertDialog.Builder builder = new AlertDialog.Builder(self);
    builder.setTitle(getString(//from   w ww .j a  va  2 s. co  m
            comment == null ? R.string.taskview_fab_new_comment : R.string.taskview_dlg_update_comment));
    final EditText input = new EditText(this);
    input.setText(comment == null ? "" : comment.getContent());
    input.setSingleLine(false);
    input.setMinLines(5);
    input.setMaxLines(10);
    input.setVerticalScrollBarEnabled(true);
    builder.setView(input);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (!input.getText().toString().contentEquals("")) {
                if (comment == null) {
                    Log.i(Constants.TAG, "Creating new comment.");
                    kanboardAPI.createComment(task.getId(), me.getId(), input.getText().toString());
                } else {
                    Log.i(Constants.TAG, "Updating comment.");
                    kanboardAPI.updateComment(comment.getId(), input.getText().toString());
                }
                dialog.dismiss();
            }
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    builder.show();
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showCvvPrompt(final PaymentOption paymentOption) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = "Please enter CVV.";
    String positiveButtonText = "OK";
    alert.setTitle("CVV");
    alert.setMessage(message);//  w w w  . ja va2  s.  com
    // Set an EditText view to get user input
    final EditText input = new EditText(getActivity());
    input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    input.setTransformationMethod(PasswordTransformationMethod.getInstance());
    InputFilter[] FilterArray = new InputFilter[1];
    FilterArray[0] = new InputFilter.LengthFilter(4);
    input.setFilters(FilterArray);
    alert.setView(input);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String cvv = input.getText().toString();
            input.clearFocus();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
            otherPaymentOption = paymentOption;
            ((CardOption) otherPaymentOption).setCardCVV(cvv);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
        }
    });

    input.requestFocus();
    alert.show();
}

From source file:com.microsoft.onedrive.apiexplorer.ItemFragment.java

/**
 * Navigates to an item by path//  w ww. java 2 s  .  c om
 * @param item the source item
 */
private void navigateByPath(final Item item) {
    final BaseApplication application = (BaseApplication) getActivity().getApplication();
    final IOneDriveClient oneDriveClient = application.getOneDriveClient();
    final Activity activity = getActivity();

    final EditText itemPath = new EditText(activity);
    itemPath.setInputType(InputType.TYPE_CLASS_TEXT);

    final DefaultCallback<Item> itemCallback = new DefaultCallback<Item>(activity) {
        @Override
        public void success(final Item item) {
            final ItemFragment fragment = ItemFragment.newInstance(item.id);
            navigateToFragment(fragment);
        }
    };

    new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_map)
            .setTitle(R.string.navigate_by_path).setView(itemPath)
            .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    dialog.dismiss();
                }
            }).setPositiveButton(R.string.navigate, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    oneDriveClient.getDrive().getItems(item.id).getItemWithPath(itemPath.getText().toString())
                            .buildRequest().expand(getExpansionOptions(oneDriveClient)).get(itemCallback);
                }
            }).create().show();
}

From source file:com.paramonod.kikos.MainActivity.java

public void makingFullStackIcon(int id, GeoPoint geoPoint) {
    OverlayItem oi = new OverlayItem(geoPoint, main.getResources().getDrawable(id));
    final BalloonItem bi = new BalloonItem(main, oi.getGeoPoint());
    if (id != R.drawable.orpgshop) {
        bi.setOnBalloonListener(new OnBalloonListener() {
            @Override//w  ww . ja v  a 2 s .c  om
            public void onBalloonViewClick(BalloonItem balloonItem, View view) {
            }

            @Override
            public void onBalloonShow(BalloonItem balloonItem) {
                Intent intent = new Intent(main, DetailActivity.class);
                int m = 0;
                for (int i = 0; i < shopInterfaces.size(); i++) {
                    GeoPoint g = new GeoPoint(shopInterfaces.get(i).getCoordX(),
                            shopInterfaces.get(i).getCoordY());
                    if (g.equals(balloonItem.getGeoPoint())) {
                        m = i;
                        //  Log.e("Search", "got here" + Integer.toString(m));
                    }
                }
                intent.putExtra(DetailActivity.EXTRA_POSITION, m);
                startActivity(intent);
            }

            @Override
            public void onBalloonHide(BalloonItem balloonItem) {

            }

            @Override
            public void onBalloonAnimationStart(BalloonItem balloonItem) {

            }

            @Override
            public void onBalloonAnimationEnd(BalloonItem balloonItem) {

            }
        });
    } else {
        bi.setOnBalloonListener(new OnBalloonListener() {
            @Override
            public void onBalloonViewClick(BalloonItem balloonItem, View view) {
            }

            @Override
            public void onBalloonShow(BalloonItem balloonItem) {
                final AlertDialog.Builder b = new AlertDialog.Builder(main);
                b.setTitle(" ?");
                b.setMessage(
                        "?   ? ?  ? ? ? ?,  ");
                b.setPositiveButton("", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        AlertDialog.Builder builder = new AlertDialog.Builder(main);
                        final EditText et = new EditText(main);
                        builder.setMessage(
                                "   ?,  ? ? ? ?  ??: "
                                        + searchView.getQuery());
                        builder.setTitle(" ");
                        builder.setView(et);
                        builder.setPositiveButton("", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                String s = et.getText().toString();
                                if (s.equals(""))
                                    s = searchView.getQuery().toString();
                                GeoPoint biGeo = bi.getGeoPoint();
                                Pair p = new Pair();
                                p.first = s;
                                p.second = biGeo;
                                places.add(p);
                                SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit();
                                String connectionsJSONString1 = new Gson().toJson(p);
                                editor.putString("places" + placesIDX, connectionsJSONString1);
                                editor.commit();
                                placesIDX++;
                            }
                        });
                        builder.show();
                    }
                });
                b.setNegativeButton("", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
                b.show();
                /* mc.getDownloader().getGeoCode(new GeoCodeListener() {
                     @Override
                     public boolean onFinishGeoCode(final GeoCode geoCode) {
                         if (geoCode != null) {
                             Log.e("Not so fucking", "title" + geoCode.getTitle() + "\nsubtitle" + geoCode.getSubtitle() + "\ndisplayname" + geoCode.getDisplayName() + "\nkind" + geoCode.getKind());
                             main.name = geoCode.getTitle();
                         } else {
                         }
                         AsyncTask asyncTask = new AsyncTask() {
                             @Override
                             protected Object doInBackground(Object[] params) {
                                 String namme = "";
                                 try {
                                     URL url = new URL("https://search-maps.yandex.ru/v1/?text=" + params[0] + "&type=biz&lang=ru_RU&apikey=245e2b86-5cfb-40c3-a064-516c37dba6b2");
                        
                                     System.out.println(url);
                                     HttpURLConnection con = (HttpURLConnection) url.openConnection();
                                     con.connect();
                                     // optional default is GET
                                     con.setRequestMethod("GET");
                                     //int responseCode = con.getResponseCode(); if smth crashes
                                     BufferedReader in = new BufferedReader(
                                             new InputStreamReader(con.getInputStream()));
                                     String inputLine;
                                     String response = "";
                        
                                     while ((inputLine = in.readLine()) != null) {
                                         response += inputLine;
                                     }
                                     in.close();
                                     con.disconnect();
                                     MapActivity.jsonObject = new JSONObject(response);
                                     JSONArray ja1 = MapActivity.jsonObject.getJSONArray("features");
                                     for (int i = 0; i < ja1.length(); i++) {
                                         JSONObject j0 = ja1.getJSONObject(i);
                                         JSONObject j11 = j0.getJSONObject("properties");
                                         main.namme += " " + j11.getString("name");
                                     }
                                 } catch (Exception e) {
                                     e.printStackTrace();
                                 }
                                 return null;
                             }
                        
                             @Override
                             protected void onPostExecute(Object o) {
                                 super.onPostExecute(o);
                                 main.selectName();
                        
                        
                        
                             }
                         }.execute(main.name);
                         return true;
                     }
                 }, balloonItem.getGeoPoint());
                 intent = new Intent(main, DetailYandexActivity.class);
                */
            }

            @Override
            public void onBalloonHide(BalloonItem balloonItem) {

            }

            @Override
            public void onBalloonAnimationStart(BalloonItem balloonItem) {

            }

            @Override
            public void onBalloonAnimationEnd(BalloonItem balloonItem) {

            }
        });
    }
    bi.setDrawable(getResources().getDrawable(R.drawable.itkerk));
    oi.setBalloonItem(bi);
    o.addOverlayItem(oi);

}

From source file:cz.muni.fi.japanesedictionary.fragments.DisplayTranslation.java

public void showNoteAlertBox(String note) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setMessage(R.string.translation_note);
    builder.setCancelable(true);//from ww  w  .  j  av  a 2  s  .  c  o  m

    final EditText input = new EditText(getActivity());

    input.setText(note);
    input.setMinHeight(200);
    builder.setView(input);

    builder.setPositiveButton(getString(R.string.save), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            String note = input.getText().toString().trim();
            mNote.setEnabled(false);
            NoteSaver noteSaver = new NoteSaver(mCallbackTranslation.getDatabase(), mNote,
                    DisplayTranslation.this, mTranslation);
            noteSaver.execute(note);
        }
    }).setNegativeButton(getString(R.string.storno), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.citrus.sample.WalletPaymentFragment.java

void showTokenizedPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    final String message = "Auto Load Money with Saved Card";
    String positiveButtonText = "Auto Load";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelamt = new TextView(getActivity());
    final EditText editAmount = new EditText(getActivity());
    final TextView labelAmount = new TextView(getActivity());
    final EditText editLoadAmount = new EditText(getActivity());
    final TextView labelMobileNo = new TextView(getActivity());
    final EditText editThresholdAmount = new EditText(getActivity());
    final Button btnSelectSavedCards = new Button(getActivity());
    btnSelectSavedCards.setText("Select Saved Card");

    editLoadAmount.setSingleLine(true);//from   ww w .j  a  v a 2s .  c o  m
    editThresholdAmount.setSingleLine(true);

    editAmount.setSingleLine(true);
    labelamt.setText("Load Amount");
    labelAmount.setText("Auto Load Amount");
    labelMobileNo.setText("Threshold Amount");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelamt.setLayoutParams(layoutParams);
    editAmount.setLayoutParams(layoutParams);
    labelAmount.setLayoutParams(layoutParams);
    labelMobileNo.setLayoutParams(layoutParams);
    editLoadAmount.setLayoutParams(layoutParams);
    editThresholdAmount.setLayoutParams(layoutParams);
    btnSelectSavedCards.setLayoutParams(layoutParams);

    btnSelectSavedCards.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCitrusClient.getWallet(new Callback<List<PaymentOption>>() {
                @Override
                public void success(List<PaymentOption> paymentOptions) {
                    walletList.clear();
                    for (PaymentOption paymentOption : paymentOptions) {
                        if (paymentOption instanceof CreditCardOption) {
                            if (Arrays.asList(AUTO_LOAD_CARD_SCHEMS)
                                    .contains(((CardOption) paymentOption).getCardScheme().toString()))
                                walletList.add(paymentOption); //only available for Master and Visa Credit Card....
                        }
                    }
                    savedOptionsAdapter = new SavedOptionsAdapter(getActivity(), walletList);
                    showSavedAccountsDialog();
                }

                @Override
                public void error(CitrusError error) {
                    Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
                }
            });
        }
    });

    linearLayout.addView(labelamt);
    linearLayout.addView(editAmount);
    linearLayout.addView(labelAmount);
    linearLayout.addView(editLoadAmount);
    linearLayout.addView(labelMobileNo);
    linearLayout.addView(editThresholdAmount);
    linearLayout.addView(btnSelectSavedCards);

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editLoadAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    editThresholdAmount.setInputType(InputType.TYPE_CLASS_NUMBER);
    alert.setTitle("Auto Load Money with Saved Card");
    alert.setMessage(message);

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            final String amount = editAmount.getText().toString();
            final String loadAmount = editLoadAmount.getText().toString();
            final String thresHoldAmount = editThresholdAmount.getText().toString();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0);

            if (TextUtils.isEmpty(amount)) {
                Toast.makeText(getActivity(), "Amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(loadAmount)) {
                Toast.makeText(getActivity(), "Load Amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(thresHoldAmount)) {
                Toast.makeText(getActivity(), "thresHoldAmount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(thresHoldAmount) < new Double("500")) {
                Toast.makeText(getActivity(), "thresHoldAmount  should not be less than 500",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(loadAmount) < new Double(thresHoldAmount)) {
                Toast.makeText(getActivity(), "Load Amount should not be less than thresHoldAmount",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            if (otherPaymentOption == null) {
                Toast.makeText(getActivity(), "Saved Card Option is null.", Toast.LENGTH_SHORT).show();
            }

            try {
                PaymentType paymentType = new PaymentType.LoadMoney(new Amount(amount), otherPaymentOption);
                mCitrusClient.autoLoadMoney((PaymentType.LoadMoney) paymentType, new Amount(thresHoldAmount),
                        new Amount(loadAmount), new Callback<SubscriptionResponse>() {
                            @Override
                            public void success(SubscriptionResponse subscriptionResponse) {
                                Logger.d("AUTO LOAD RESPONSE ***"
                                        + subscriptionResponse.getSubscriptionResponseMessage());
                                Toast.makeText(getActivity(),
                                        subscriptionResponse.getSubscriptionResponseMessage(),
                                        Toast.LENGTH_SHORT).show();
                            }

                            @Override
                            public void error(CitrusError error) {
                                Logger.d("AUTO LOAD ERROR ***" + error.getMessage());
                                Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
                            }
                        });
            } catch (CitrusException e) {
                e.printStackTrace();
            }
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editLoadAmount.requestFocus();
    alert.show();
}

From source file:com.hichinaschool.flashcards.anki.CardEditor.java

@Override
protected Dialog onCreateDialog(int id) {
    StyledDialog dialog = null;/*from  www  .j  ava  2s  . c om*/
    Resources res = getResources();
    StyledDialog.Builder builder = new StyledDialog.Builder(this);

    switch (id) {
    case DIALOG_TAGS_SELECT:
        builder.setTitle(R.string.card_details_tags);
        builder.setPositiveButton(res.getString(R.string.select), new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (mAddNote) {
                    try {
                        JSONArray ja = new JSONArray();
                        for (String t : selectedTags) {
                            ja.put(t);
                        }
                        mCol.getModels().current().put("tags", ja);
                        mCol.getModels().setChanged();
                    } catch (JSONException e) {
                        throw new RuntimeException(e);
                    }
                    mEditorNote.setTags(selectedTags);
                }
                mCurrentTags = selectedTags;
                updateTags();
            }
        });
        builder.setNegativeButton(res.getString(R.string.cancel), null);

        mNewTagEditText = (EditText) new EditText(this);
        mNewTagEditText.setHint(R.string.add_new_tag);

        InputFilter filter = new InputFilter() {
            public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                    int dend) {
                for (int i = start; i < end; i++) {
                    if (source.charAt(i) == ' ' || source.charAt(i) == ',') {
                        return "";
                    }
                }
                return null;
            }
        };
        mNewTagEditText.setFilters(new InputFilter[] { filter });

        ImageView mAddTextButton = new ImageView(this);
        mAddTextButton.setImageResource(R.drawable.ic_addtag);
        mAddTextButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String tag = mNewTagEditText.getText().toString();
                if (tag.length() != 0) {
                    if (mEditorNote.hasTag(tag)) {
                        mNewTagEditText.setText("");
                        return;
                    }
                    selectedTags.add(tag);
                    actualizeTagDialog(mTagsDialog);
                    mNewTagEditText.setText("");
                }
            }
        });

        FrameLayout frame = new FrameLayout(this);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
        params.rightMargin = 10;
        mAddTextButton.setLayoutParams(params);
        frame.addView(mNewTagEditText);
        frame.addView(mAddTextButton);

        builder.setView(frame, false, true);
        dialog = builder.create();
        mTagsDialog = dialog;
        break;

    case DIALOG_DECK_SELECT:
        ArrayList<CharSequence> dialogDeckItems = new ArrayList<CharSequence>();
        // Use this array to know which ID is associated with each
        // Item(name)
        final ArrayList<Long> dialogDeckIds = new ArrayList<Long>();

        ArrayList<JSONObject> decks = mCol.getDecks().all();
        Collections.sort(decks, new JSONNameComparator());
        builder.setTitle(R.string.deck);
        for (JSONObject d : decks) {
            try {
                if (d.getInt("dyn") == 0) {
                    dialogDeckItems.add(d.getString("name"));
                    dialogDeckIds.add(d.getLong("id"));
                }
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }
        // Convert to Array
        String[] items = new String[dialogDeckItems.size()];
        dialogDeckItems.toArray(items);

        builder.setItems(items, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                long newId = dialogDeckIds.get(item);
                if (mCurrentDid != newId) {
                    if (mAddNote) {
                        try {
                            // TODO: mEditorNote.setDid(newId);
                            mEditorNote.model().put("did", newId);
                            mCol.getModels().setChanged();
                        } catch (JSONException e) {
                            throw new RuntimeException(e);
                        }
                    }
                    mCurrentDid = newId;
                    updateDeck();
                }
            }
        });

        dialog = builder.create();
        mDeckSelectDialog = dialog;
        break;

    case DIALOG_MODEL_SELECT:
        ArrayList<CharSequence> dialogItems = new ArrayList<CharSequence>();
        // Use this array to know which ID is associated with each
        // Item(name)
        final ArrayList<Long> dialogIds = new ArrayList<Long>();

        ArrayList<JSONObject> models = mCol.getModels().all();
        Collections.sort(models, new JSONNameComparator());
        builder.setTitle(R.string.note_type);
        for (JSONObject m : models) {
            try {
                dialogItems.add(m.getString("name"));
                dialogIds.add(m.getLong("id"));
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }
        // Convert to Array
        String[] items2 = new String[dialogItems.size()];
        dialogItems.toArray(items2);

        builder.setItems(items2, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                long oldModelId;
                try {
                    oldModelId = mCol.getModels().current().getLong("id");
                } catch (JSONException e) {
                    throw new RuntimeException(e);
                }
                long newId = dialogIds.get(item);
                if (oldModelId != newId) {
                    mCol.getModels().setCurrent(mCol.getModels().get(newId));
                    JSONObject cdeck = mCol.getDecks().current();
                    try {
                        cdeck.put("mid", newId);
                    } catch (JSONException e) {
                        throw new RuntimeException(e);
                    }
                    mCol.getDecks().save(cdeck);
                    int size = mEditFields.size();
                    String[] oldValues = new String[size];
                    for (int i = 0; i < size; i++) {
                        oldValues[i] = mEditFields.get(i).getText().toString();
                    }
                    setNote();
                    resetEditFields(oldValues);
                    mTimerHandler.removeCallbacks(checkDuplicatesRunnable);
                    duplicateCheck(false);
                }
            }
        });
        dialog = builder.create();
        break;

    case DIALOG_RESET_CARD:
        builder.setTitle(res.getString(R.string.reset_card_dialog_title));
        builder.setMessage(res.getString(R.string.reset_card_dialog_message));
        builder.setPositiveButton(res.getString(R.string.yes), new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // for (long cardId :
                // mDeck.getCardsFromFactId(mEditorNote.getId())) {
                // mDeck.cardFromId(cardId).resetCard();
                // }
                // mDeck.reset();
                // setResult(Reviewer.RESULT_EDIT_CARD_RESET);
                // mCardReset = true;
                // Themes.showThemedToast(CardEditor.this,
                // getResources().getString(
                // R.string.reset_card_dialog_confirmation), true);
            }
        });
        builder.setNegativeButton(res.getString(R.string.no), null);
        builder.setCancelable(true);
        dialog = builder.create();
        break;

    case DIALOG_INTENT_INFORMATION:
        dialog = createDialogIntentInformation(builder, res);
    }

    return dialog;
}