Example usage for android.app Dialog findViewById

List of usage examples for android.app Dialog findViewById

Introduction

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

Prototype

@Nullable
public <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID or null if the ID is invalid (< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via #show() or #create() ).

Usage

From source file:com.angelhack.person2person.AbstractGetNameTask.java

@Override
protected void onPostExecute(Void result) {
    // TODO Auto-generated method stub
    super.onPostExecute(result);

    try {//from   w  ww  .j  ava  2 s. c o m
        System.out.println("On Home Page***" + AbstractGetNameTask.GOOGLE_USER_DATA);
        JSONObject profileData = new JSONObject(AbstractGetNameTask.GOOGLE_USER_DATA);

        if (profileData.has("picture")) {
            SocialMedia_New.userImageUrl = profileData.getString("picture");

        }
        if (profileData.has("name")) {
            SocialMedia_New.textName = profileData.getString("name");
            //      SocialMedia_New.textViewName.setText(SocialMedia_New.textName);
        }

        dialog.dismiss();

        final Dialog alert_dialog = new Dialog(mActivity);
        alert_dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        alert_dialog.setContentView(R.layout.dialog_custom);

        TextView content = (TextView) alert_dialog.findViewById(R.id.content_tv_id);
        TextView ok = (TextView) alert_dialog.findViewById(R.id.ok_tv_id);
        profile = (ImageView) alert_dialog.findViewById(R.id.image_id);

        new GetImageFromUrl().execute(SocialMedia_New.userImageUrl);

        content.setText(" Welcome  " + SocialMedia_New.textName);
        ok.setText("Stay Connect with Us..!");

        ok.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                Intent intent = new Intent(mActivity, Home_Activity.class);
                mActivity.startActivity(intent);

                mActivity.overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);

                mActivity.finish();

            }
        });

        alert_dialog.show();

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.flowzr.activity.DateFilterActivity.java

@Override
protected Dialog onCreateDialog(final int id) {
    final Dialog d = new Dialog(this);
    d.setCancelable(true);//ww w  .  j  av  a2 s.c om
    d.setTitle(id == 1 ? R.string.period_from : R.string.period_to);
    d.setContentView(R.layout.filter_period_select);
    Button bOk = (Button) d.findViewById(R.id.bOK);
    bOk.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setDialogResult(d, id == 1 ? cFrom : cTo);
            d.dismiss();
        }
    });
    Button bCancel = (Button) d.findViewById(R.id.bCancel);
    bCancel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            d.cancel();
        }
    });
    return d;
}

From source file:org.feedhenry.blank.MainActivity.java

private void createDialog(String action, final Item item) {
    final Dialog newDialog = new Dialog(this);
    newDialog.setContentView(R.layout.dialog);
    // Edit text//w  w  w .j av a 2 s .com
    final EditText userInput = (EditText) newDialog.findViewById(R.id.newitemtext);
    TextView title = (TextView) newDialog.findViewById(R.id.title);
    ///OK Button
    Button okDialogButton = (Button) newDialog.findViewById(R.id.okbutton);
    // Cancel Button
    Button cancelDialogButton = (Button) newDialog.findViewById(R.id.cancelbutton);
    cancelDialogButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            newDialog.dismiss();
        }
    });

    if (action.matches("newitem")) {
        //newDialog.setTitle("Enter New Name");
        title.setText("Enter New Name");
        okDialogButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (userInput.getText().length() > 0) {
                    sendNewItemToCloud(userInput.getText().toString());
                    userInput.setText("");
                }
                newDialog.dismiss();
            }
        });
        newDialog.show();
    } else if (action.matches("updateitem")) {
        title.setText("Update Name");
        userInput.setText(item.getName());
        okDialogButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (userInput.getText().length() > 0) {
                    updateItemToCloud(userInput.getText().toString(), item);
                    userInput.setText("");
                }
                newDialog.dismiss();
            }
        });
        newDialog.show();
    } else if (action.matches("deleteitem")) {
        title.setText("Delete Name");
        userInput.setText(item.getName());
        userInput.setFocusable(false);
        okDialogButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (userInput.getText().length() > 0) {
                    deleteItemFromCloud(userInput.getText().toString(), item);
                    userInput.setText("");
                }
                newDialog.dismiss();
            }
        });
        newDialog.show();
    }
}

From source file:com.givon.baseproject.xinlu.act.ActRegist.java

public void showDialog(final String phone, final String code) {
    int resId = getStyleRes(this, "CommonDialog");
    if (resId > 0) {
        final String phoneNum = "+" + code + " " + splitPhoneNum(phone);
        final Dialog dialog = new Dialog(this, resId);
        resId = getLayoutRes(this, "smssdk_send_msg_dialog");
        if (resId > 0) {
            dialog.setContentView(resId);
            resId = getIdRes(this, "tv_phone");
            ((TextView) dialog.findViewById(resId)).setText(phoneNum);
            resId = getIdRes(this, "tv_dialog_hint");
            TextView tv = (TextView) dialog.findViewById(resId);
            resId = getStringRes(this, "smssdk_make_sure_mobile_detail");
            if (resId > 0) {
                String text = this.getString(resId);
                tv.setText(Html.fromHtml(text));
            }/*from   w  w w . j a va  2  s .c  om*/
            resId = getIdRes(this, "btn_dialog_ok");
            if (resId > 0) {
                ((Button) dialog.findViewById(resId)).setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        // ???
                        dialog.dismiss();
                        Log.e("verification phone ==>>", phone);
                        showWaitingDialog();
                        SMSSDK.getVerificationCode(code, phone.trim());
                    }
                });
            }
            resId = getIdRes(this, "btn_dialog_cancel");
            if (resId > 0) {
                ((Button) dialog.findViewById(resId)).setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });
            }
            dialog.setCanceledOnTouchOutside(true);
            dialog.show();
        }
    }
}

From source file:com.akhbulatov.wordkeeper.ui.fragment.WordListFragment.java

/**
 * Receives the entered data (word) and saves in the database
 *
 * @param dialog The dialog from where take the data (word) to save
 *//*w w w  .  jav  a 2 s.c om*/
public void addWord(DialogFragment dialog) {
    Dialog dialogView = dialog.getDialog();

    EditText editName = dialogView.findViewById(R.id.edit_word_name);
    EditText editTranslation = dialogView.findViewById(R.id.edit_word_translation);
    Spinner spinnerCategory = dialogView.findViewById(R.id.spinner_categories);

    String name = editName.getText().toString();
    String translation = editTranslation.getText().toString();
    String category = spinnerCategory.getSelectedItem().toString();

    if ((TextUtils.isEmpty(name) & TextUtils.isEmpty(translation))
            | (TextUtils.isEmpty(name) | TextUtils.isEmpty(translation))) {
        CommonUtils.showToast(getActivity(), R.string.error_word_editor_empty_fields);
    } else {
        mWordDbAdapter.insert(new Word(name, translation, category));
        // Checked for null in case this method is called from the screen "Categories"
        if (mWordList != null) {
            mWordList.scrollToPosition(0);
        }
        getLoaderManager().restartLoader(LOADER_ID, null, this);
    }
}

From source file:org.mariotaku.twidere.fragment.RetweetQuoteDialogFragment.java

@CheckResult
private boolean retweetOrQuote(ParcelableAccount account, ParcelableStatus status,
        boolean showProtectedConfirmation) {
    AsyncTwitterWrapper twitter = mTwitterWrapper;
    final Dialog dialog = getDialog();
    if (dialog == null || twitter == null)
        return false;
    final EditText editComment = (EditText) dialog.findViewById(R.id.edit_comment);
    if (useQuote(editComment.length() > 0, account)) {
        final Menu menu = mPopupMenu.getMenu();
        final MenuItem itemQuoteOriginalStatus = menu.findItem(R.id.quote_original_status);
        final Uri statusLink;
        final boolean quoteOriginalStatus = itemQuoteOriginalStatus.isChecked();

        String commentText;// w  w w .j a v  a 2s . c o m
        final ParcelableStatusUpdate update = new ParcelableStatusUpdate();
        update.accounts = new ParcelableAccount[] { account };
        final String editingComment = String.valueOf(editComment.getText());
        switch (ParcelableAccountUtils.getAccountType(account)) {
        case ParcelableAccount.Type.FANFOU: {
            if (!status.is_quote || !quoteOriginalStatus) {
                if (status.user_is_protected && showProtectedConfirmation) {
                    QuoteProtectedStatusWarnFragment.show(this, account, status);
                    return false;
                }
                update.repost_status_id = status.id;
                commentText = getString(R.string.fanfou_repost_format, editingComment, status.user_screen_name,
                        status.text_plain);
            } else {
                if (status.quoted_user_is_protected && showProtectedConfirmation) {
                    return false;
                }
                commentText = getString(R.string.fanfou_repost_format, editingComment,
                        status.quoted_user_screen_name, status.quoted_text_plain);
                update.repost_status_id = status.quoted_id;
            }
            if (commentText.length() > Validator.MAX_TWEET_LENGTH) {
                commentText = commentText.substring(0,
                        Math.max(Validator.MAX_TWEET_LENGTH, editingComment.length()));
            }
            break;
        }
        default: {
            if (!status.is_quote || !quoteOriginalStatus) {
                statusLink = LinkCreator.getStatusWebLink(status);
            } else {
                statusLink = LinkCreator.getQuotedStatusWebLink(status);
            }
            update.attachment_url = statusLink.toString();
            commentText = editingComment;
            break;
        }
        }
        update.text = commentText;
        update.is_possibly_sensitive = status.is_possibly_sensitive;
        BackgroundOperationService.updateStatusesAsync(getContext(), Draft.Action.QUOTE, update);
    } else {
        twitter.retweetStatusAsync(status.account_key, status.id);
    }
    return true;
}

From source file:no.barentswatch.fiskinfo.MyPageActivity.java

public void createSubscriptionInformationDialog(int JSONObjectIndex) {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setContentView(R.layout.subscription_info_dialog);

    TextView subscriptionNameView = (TextView) dialog.findViewById(R.id.subscription_description_text_view);
    TextView subscriptionOwnerView = (TextView) dialog.findViewById(R.id.subscription_owner_text_view);
    TextView subscriptionUpdatedView = (TextView) dialog.findViewById(R.id.subscription_last_updated_text_view);
    Button okButton = (Button) dialog.findViewById(R.id.dismiss_dialog_button);
    Button viewOnMapButton = (Button) dialog.findViewById(R.id.go_to_map_button);
    String subscriptionName = null;
    String subscriptionOwner = null;
    String subscriptionDescription = null;

    JSONArray subscriptions = getSharedCacheOfAvailableSubscriptions();
    List<String> updateValues = new ArrayList<String>();
    JSONObject currentSubscription;/*from   www. j a  v a 2s .co m*/
    String lastUpdated = "";

    updateValues.add("Name");
    updateValues.add("DataOwner");
    updateValues.add("LastUpdated");
    updateValues.add("Description");
    updateValues.add("UpdateFrequencyText");

    if (subscriptions != null) {
        try {
            currentSubscription = getSharedCacheOfAvailableSubscriptions().getJSONObject(JSONObjectIndex);
            subscriptionName = currentSubscription.getString("Name");
            subscriptionOwner = currentSubscription.getString("DataOwner");
            subscriptionDescription = currentSubscription.getString("Description");
            lastUpdated = currentSubscription.get("LastUpdated").toString();
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    String[] updateDateAndTime = lastUpdated.split("T");
    lastUpdated = updateDateAndTime[1] + "  " + updateDateAndTime[0];

    subscriptionNameView.setText(subscriptionDescription);
    subscriptionOwnerView.setText(subscriptionOwner);
    subscriptionUpdatedView.setText(lastUpdated);

    okButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    viewOnMapButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Do some map stuff here so we only show this layer I
            // guess?
            loadView(MapActivity.class);
        }
    });

    int subscriptionIconId = getSubscriptionIconId(subscriptionName);

    dialog.setTitle(subscriptionName);
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
    if (subscriptionIconId != 0) {
        dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, subscriptionIconId);
    }

}

From source file:com.example.com.benasque2014.mercurio.FamiliaMapaFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_details) {
        Dialog d = new Dialog(getActivity());
        d.setTitle("Detalles del trayecto");
        d.setContentView(R.layout.dialog_details);
        TextView text = (TextView) d.findViewById(R.id.text);
        text.setText("");
        text.append("Nombre: " + recorrido.getName() + "\n");
        text.append("Cdigo: " + recorrido.getCodigo() + "\n");
        text.append("Clase: " + recorrido.getClase() + "\n");
        text.append("Hora inicio: " + recorrido.getHoraInicio() + "\n");
        text.append("Hora fin: " + recorrido.getHoraFin() + "\n");
        text.append("Frecuencia: " + recorrido.getFrecuencia() + "\n");
        text.append("Incidencia: " + recorrido.getIncidencia() + "\n");
        d.show();/*from ww  w.  j a  va  2 s .  c o  m*/
    }
    return super.onOptionsItemSelected(item);
}

From source file:me.isassist.isa.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    if (id == R.id.action_refresh) {
        if (!isNetworkAvailable()) {
            Toast.makeText(this, "No internet connection available!", Toast.LENGTH_LONG).show();
            return true;
        }//  ww w .  j a  va 2s .  c  o m
        showLoadingFragment("Updating\nThis can take a while\n Please wait!");
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        }

        for (Bihapi b : Bihapi.values())
            new FetchAPI(this, this, b, FetchAPI.FetchType.INTERNET).execute();
        return true;
    } else if (id == R.id.action_about) {
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.about_dialog);
        dialog.setTitle("About");

        TextView text = (TextView) dialog.findViewById(R.id.licensesText);
        text.setText(Html.fromHtml(
                "Building, Tall, Trading, Human graphics by <a href=\"http://www.freepik.com/\">Freepik</a> and Building graphic by <a href=\"http://www.unocha.org\">Ocha</a> and Haw Gestures Stroke graphic by <a href=\"http://yanlu.de\">Yannick</a> from <a href=\"http://www.flaticon.com/\">Flaticon</a> are licensed under <a href=\"http://creativecommons.org/licenses/by/3.0/\" title=\"Creative Commons BY 3.0\">CC BY 3.0</a>.Park graphic by <a href=\"http://www.freepik.com\">Freepik</a> from <a href=\"http://www.flaticon.com/\">Flaticon</a> is licensed under <a href=\"http://creativecommons.org/licenses/by/3.0/\" title=\"Creative Commons BY 3.0\">CC BY 3.0</a>. Made with <a href=\"http://logomakr.com\" title=\"Logo Maker\">Logo Maker</a>"));

        dialog.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:transapps.gpxfitness.ui.MainActivity.java

public void profileAlertDialog() {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.profile_dialog);
    dialog.setTitle("Please Enter Profile:");
    dialog.setCancelable(false);/*w  w  w. java2s. co m*/

    Button ok_button = (Button) dialog.findViewById(R.id.button);
    ok_button.setText("Ok");
    final EditText username = (EditText) dialog.findViewById(R.id.username);
    final EditText height_ft = (EditText) dialog.findViewById(R.id.height_ft);
    final EditText height_in = (EditText) dialog.findViewById(R.id.height_in);
    final EditText weight_lbs = (EditText) dialog.findViewById(R.id.weight_lbs);
    final EditText age_yrs = (EditText) dialog.findViewById(R.id.age_yrs);
    final RadioButton male = (RadioButton) dialog.findViewById(R.id.male);
    final EditText[] et = { username, height_ft, height_in, weight_lbs, age_yrs };
    ok_button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            String user_string = username.getText().toString();
            String height_ft_string = height_ft.getText().toString();
            String height_in_string = height_in.getText().toString();
            String weight_lbs_string = weight_lbs.getText().toString();
            String age_yrs_string = age_yrs.getText().toString();
            boolean are_any_empty = false;
            for (EditText e : et) {
                String str = e.getText().toString();
                if (str == null || str.length() == 0)
                    are_any_empty = true;
            }
            if (!are_any_empty) {
                int height = Integer.parseInt(height_ft_string) * 12 + Integer.parseInt(height_in_string);
                String sex;
                if (male.isChecked())
                    sex = "male";
                else
                    sex = "female";
                ProfileAccessor.createNewProfile(user_string, height, Integer.parseInt(weight_lbs_string), sex,
                        Integer.parseInt(age_yrs_string));
                dialog.dismiss();
            }
        }
    });

    dialog.show();
}