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.inc.playground.playgroundApp.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    globalVariables = ((GlobalVariables) getApplication());
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    setPlayGroundActionBar();// w ww.j  a va  2  s.  c  o  m
    //set actionBar color
    actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.primaryColor)));
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.secondaryColor)));
    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    //actionBar.setHomeButtonEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(actionBar.newTab().setTabListener(this));
    }
    actionBar.getTabAt(0).setIcon(R.drawable.pg_list_view);
    actionBar.getTabAt(1).setIcon(R.drawable.pg_map_view);
    //NavigationDrawer handling (e.g the list from leftside):
    mTitle = mDrawerTitle = getTitle();
    mDrawerLayout = (DrawerLayout) findViewById(R.id.menu_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.pg_menu, /* nav drawer icon to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description */
            R.string.drawer_close /* "close drawer" description */
    ) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            getActionBar().setTitle(mTitle);
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            getActionBar().setTitle(mDrawerTitle);
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerLayout.closeDrawers();
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    // all linear layout from slider menu

    /*Home button */
    LinearLayout ll_Home = (LinearLayout) findViewById(R.id.ll_home);
    ll_Home.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // new changes
            Intent iv = new Intent(MainActivity.this, MainActivity.class);
            startActivity(iv);
            finish();
        }
    });
    /*Login button */
    LinearLayout ll_Login = (LinearLayout) findViewById(R.id.ll_login);
    ll_Login.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // new changes
            LinearLayout ll_Login = (LinearLayout) v;
            TextView loginTxt = (TextView) findViewById(R.id.login_txt);
            if (loginTxt.getText().equals("Login")) {
                Intent iv = new Intent(MainActivity.this, Login.class);
                startActivity(iv);
                finish();
            } else if (loginTxt.getText().equals("Logout")) {
                final Dialog alertDialog = new Dialog(MainActivity.this);
                alertDialog.setContentView(R.layout.logout_dilaog);
                alertDialog.setTitle("Logout");
                alertDialog.findViewById(R.id.ok_btn).setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {

                        SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
                        SharedPreferences.Editor editor = prefs.edit();
                        editor.clear();
                        editor.commit();
                        ImageView loginImg = (ImageView) findViewById(R.id.login_img);
                        TextView loginTxt = (TextView) findViewById(R.id.login_txt);
                        loginTxt.setText("Login");
                        loginImg.setImageResource(R.drawable.pg_action_lock_open);

                        globalVariables = ((GlobalVariables) getApplication());
                        globalVariables.SetCurrentUser(null);
                        globalVariables.SetUserPictureBitMap(null);
                        globalVariables.SetUsersList(null);
                        globalVariables.SetUsersImagesMap(null);

                        Util.clearCookies(getApplicationContext());

                        Intent iv = new Intent(MainActivity.this, MainActivity.class);
                        startActivity(iv);
                        finish();
                    }
                });

                alertDialog.findViewById(R.id.cancel_btn).setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        Intent iv = new Intent(MainActivity.this, MainActivity.class);
                        startActivity(iv);
                        finish();
                    }
                });

                alertDialog.show(); //<-- See This!
            }

        }
    });
    //
    //        /*Setting button*/
    //        LinearLayout ll_Setting = (LinearLayout) findViewById(R.id.ll_settings);
    //        ll_Setting.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                // TODO Auto-generated method stub
    //                // new changes
    //                Intent iv = new Intent(MainActivity.this,
    //                        com.inc.playground.playgroundApp.upLeft3StripesButton.
    //                                SettingsActivity.class);
    //                startActivity(iv);
    //                finish();
    //            }
    //        });

    /*My profile button*/
    LinearLayout ll_my_profile = (LinearLayout) findViewById(R.id.ll_my_profile);
    ll_my_profile.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // new changes
            globalVariables = ((GlobalVariables) getApplication());
            User currentUser = globalVariables.GetCurrentUser();
            if ((currentUser == null) || (currentUser != null && currentUser.GetUserId() == null)) {
                Toast.makeText(MainActivity.this, "You are not logged in", Toast.LENGTH_LONG).show();
            } else {

                Intent iv = new Intent(MainActivity.this,
                        com.inc.playground.playgroundApp.upLeft3StripesButton.MyProfile.class);

                //for my profile
                iv.putExtra("name", currentUser.getName());
                iv.putExtra("createdNumOfEvents", currentUser.getCreatedNumOfEvents());
                //pass events
                iv.putExtra("events", currentUser.getEvents());
                iv.putExtra("events_wait4approval", currentUser.getEvents_wait4approval());
                iv.putExtra("events_decline", currentUser.getEvents_decline());

                iv.putExtra("photoUrl", currentUser.getPhotoUrl());
                startActivity(iv);
                //
            }
        }
    });

    LinearLayout ll_aboutUs = (LinearLayout) findViewById(R.id.ll_about);
    ll_aboutUs.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // new changes
            Intent iv = new Intent(MainActivity.this, AboutUs.class);
            startActivity(iv);
            finish();
        }
    });

}

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

/**
 * //from w w w . ja  v  a2s  .  co m
 */
public void showMapLayersDialog() {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setContentView(R.layout.dialog_select_map_layers);

    final LinearLayout mapLayerLayout = (LinearLayout) dialog.findViewById(R.id.map_layers_checkbox_layout);
    Button okButton = (Button) dialog.findViewById(R.id.dismiss_dialog_button);
    Button cancelButton = (Button) dialog.findViewById(R.id.go_to_map_button);

    for (int i = 0; i < 5; i++) {
        View mapLayerRow = getMapLayerCheckBoxRow(getContext(), Integer.toString(i));
        mapLayerLayout.addView(mapLayerRow);
    }

    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            for (int i = 0; i < mapLayerLayout.getChildCount(); i++) {
                if (((CheckBox) ((TableRow) mapLayerLayout.getChildAt(i)).getChildAt(0)).isChecked()) {
                    // TODO: Add layer to list

                }
            }
            // TODO: Implement logic for adding map layers here.            

            dialog.dismiss();
        }
    });

    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.setTitle(R.string.choose_map_layers);
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
}

From source file:edu.berkeley.boinc.PrefsFragment.java

private void setupDialogButtons(final PrefsListItemWrapper item, final Dialog dialog) {
    // confirm/*from  w  w  w  .j ava2s . co  m*/
    Button confirm = (Button) dialog.findViewById(R.id.confirm);
    confirm.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (item.ID == R.string.battery_charge_min_pct_header
                    || item.ID == R.string.prefs_disk_max_pct_header
                    || item.ID == R.string.prefs_cpu_time_max_header
                    || item.ID == R.string.prefs_cpu_other_load_suspension_header
                    || item.ID == R.string.prefs_memory_max_idle_header) {
                SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);
                double value = slider.getProgress() * 10;
                writeClientValuePreference(item.ID, value);
            } else if (item.ID == R.string.prefs_cpu_number_cpus_header) {
                SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);
                int sbProgress = slider.getProgress();
                double value = numberCpuCoresToPct(sbProgress <= 0 ? 1 : sbProgress + 1);
                writeClientValuePreference(item.ID, value);
            } else if (item.ID == R.string.prefs_gui_log_level_header) {
                SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);
                int sbProgress = slider.getProgress();
                try {
                    // monitor and UI in two different processes. set static variable in both
                    Logging.setLogLevel(sbProgress);
                    BOINCActivity.monitor.setLogLevel(sbProgress);
                } catch (RemoteException e) {
                }
                updateValuePref(item.ID, (double) sbProgress);
                updateLayout();
            } else if (item.ID == R.string.prefs_network_daily_xfer_limit_mb_header
                    || item.ID == R.string.battery_temperature_max_header
                    || item.ID == R.string.prefs_disk_min_free_gb_header
                    || item.ID == R.string.prefs_disk_access_interval_header) {
                EditText edit = (EditText) dialog.findViewById(R.id.Input);
                String input = edit.getText().toString();
                Double valueTmp = parseInputValueToDouble(input);
                if (valueTmp == null)
                    return;
                double value = valueTmp;
                writeClientValuePreference(item.ID, value);
            }
            dialog.dismiss();
        }
    });
    // cancel
    Button cancel = (Button) dialog.findViewById(R.id.cancel);
    cancel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}

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

/**
 * Registers an OnClickListener for a dialogs cancel-button with id
 * <code>R.id.ButtonCancel</code>
 * //  w  ww .  j ava2s. com
 * @param dialog
 *            The Dialog containing a <code>R.id.ButtonCancel</code>
 */
private void dialogRegisterCancel(final Dialog dialog) {
    Button buttonCancel = (Button) dialog.findViewById(R.id.ButtonCancel);

    buttonCancel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}

From source file:com.tingtingapps.securesms.ConversationListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
    final View view = inflater.inflate(R.layout.conversation_list_fragment, container, false);
    reminderView = (ReminderView) view.findViewById(R.id.reminder);
    list = (RecyclerView) view.findViewById(R.id.list);
    fab = (FloatingActionButton) view.findViewById(R.id.fab);
    list.setHasFixedSize(true);//from  ww  w. j  ava2  s.co  m
    list.setLayoutManager(new LinearLayoutManager(getActivity()));

    Calendar calendar = Calendar.getInstance();
    int day = calendar.get(Calendar.DAY_OF_WEEK);
    int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
    SharedPreferences sp1 = getActivity().getSharedPreferences("myPrefs", Activity.MODE_PRIVATE);
    int dayShowPopup = sp1.getInt("dayShowPopup", 0);
    /*
    //test data
    day = 7;
    dayShowPopup = 15;
    dayOfMonth = 26;*/

    if (day == 7 && dayOfMonth != dayShowPopup) {

        SharedPreferences sp2 = getActivity().getSharedPreferences("myPrefs", Activity.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp2.edit();
        editor.putInt("dayShowPopup", dayOfMonth);
        editor.commit();

        final Dialog dialogRating = new Dialog(getActivity());
        dialogRating.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialogRating.setContentView(R.layout.dlg_rating_sharing_donating);
        int height = 850;
        dialogRating.getWindow().setLayout(LinearLayout.LayoutParams.FILL_PARENT, height);
        dialogRating.setCancelable(true);

        dialogRating.show();
        Button btnRate = (Button) dialogRating.findViewById(R.id.btn_rate);
        btnRate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Context context = getActivity().getApplicationContext();
                String packageName = context.getPackageName();
                Intent intentRateApp = new Intent(Intent.ACTION_VIEW);
                intentRateApp.setData(Uri.parse("market://details?id=" + packageName));
                startActivity(intentRateApp);
            }
        });

        /*Button btnRemoveAds = (Button) dialogRating.findViewById(R.id.btn_remove_ads);
        btnRemoveAds.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intentInAppBilling = new Intent(getActivity(), InAppBillingActivity.class);
            startActivity(intentInAppBilling);
          }
        });*/

        Button btnShare = (Button) dialogRating.findViewById(R.id.btn_share);
        btnShare.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
                sharingIntent.setType("text/plain");
                String shareBody = getString(R.string.socail_share_body);
                sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                        getString(R.string.socail_share_title));
                sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
                startActivity(Intent.createChooser(sharingIntent, getString(R.string.socail_share_via)));
            }
        });

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

    return view;
}

From source file:com.adithya321.sharesanalysis.fragments.PurchaseShareFragment.java

@Nullable
@Override/*from   w w w. ja  va  2  s  . com*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_share_purchase, container, false);

    databaseHandler = new DatabaseHandler(getContext());
    sharePurchasesRecyclerView = (RecyclerView) root.findViewById(R.id.share_purchases_recycler_view);
    emptyTV = (TextView) root.findViewById(R.id.empty);
    arrow = (ImageView) root.findViewById(R.id.arrow);
    setRecyclerViewAdapter();

    FloatingActionButton addPurchaseFab = (FloatingActionButton) root.findViewById(R.id.add_purchase_fab);
    addPurchaseFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Dialog dialog = new Dialog(getContext());
            dialog.setTitle("Add Share Purchase");
            dialog.setContentView(R.layout.dialog_add_share_purchase);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            final AutoCompleteTextView name = (AutoCompleteTextView) dialog.findViewById(R.id.share_name);
            List<String> nseList = ShareUtils.getNseList(getContext());
            ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(getContext(),
                    android.R.layout.simple_dropdown_item_1line, nseList);
            name.setAdapter(arrayAdapter);

            final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner);
            ArrayList<String> shares = new ArrayList<>();
            for (Share share : sharesList) {
                shares.add(share.getName());
            }
            ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(),
                    android.R.layout.simple_spinner_item, shares);
            spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(spinnerAdapter);

            final RadioButton newRB = (RadioButton) dialog.findViewById(R.id.radioBtn_new);
            RadioButton existingRB = (RadioButton) dialog.findViewById(R.id.radioBtn_existing);
            if (shares.size() == 0)
                existingRB.setVisibility(View.GONE);
            (newRB).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    name.setVisibility(View.VISIBLE);
                    spinner.setVisibility(View.GONE);
                }
            });

            (existingRB).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    name.setVisibility(View.GONE);
                    spinner.setVisibility(View.VISIBLE);
                }
            });

            Calendar calendar = Calendar.getInstance();
            year_start = calendar.get(Calendar.YEAR);
            month_start = calendar.get(Calendar.MONTH) + 1;
            day_start = calendar.get(Calendar.DAY_OF_MONTH);
            final Button selectDate = (Button) dialog.findViewById(R.id.select_date);
            selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/")
                    .append(year_start));
            selectDate.setOnClickListener(this);

            Button addPurchaseBtn = (Button) dialog.findViewById(R.id.add_purchase_btn);
            addPurchaseBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Share share = new Share();
                    share.setId(databaseHandler.getNextKey("share"));
                    share.setPurchases(new RealmList<Purchase>());
                    Purchase purchase = new Purchase();
                    purchase.setId(databaseHandler.getNextKey("purchase"));

                    if (newRB.isChecked()) {
                        String sName = name.getText().toString().trim();
                        if (sName.equals("")) {
                            Toast.makeText(getActivity(), "Invalid Name", Toast.LENGTH_SHORT).show();
                            return;
                        } else {
                            share.setName(sName);
                            purchase.setName(sName);
                        }
                    }

                    String stringStartDate = year_start + " " + month_start + " " + day_start;
                    DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH);
                    try {
                        Date date = format.parse(stringStartDate);
                        share.setDateOfInitialPurchase(date);
                        purchase.setDate(date);
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares);
                    try {
                        purchase.setQuantity(Integer.parseInt(quantity.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText price = (EditText) dialog.findViewById(R.id.buying_price);
                    try {
                        purchase.setPrice(Double.parseDouble(price.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    purchase.setType("buy");
                    if (newRB.isChecked()) {
                        if (!databaseHandler.addShare(share, purchase)) {
                            Toast.makeText(getActivity(), "Share Already Exists", Toast.LENGTH_SHORT).show();
                            return;
                        }
                    } else {
                        purchase.setName(spinner.getSelectedItem().toString());
                        databaseHandler.addPurchase(spinner.getSelectedItem().toString(), purchase);
                    }
                    setRecyclerViewAdapter();
                    dialog.dismiss();
                }
            });
        }
    });

    return root;
}

From source file:com.vkassin.mtrade.Common.java

public static void putOrder(final Context ctx, Quote quote) {

    final Instrument it = Common.selectedInstrument;// adapter.getItem(selectedRowId);

    final Dialog dialog = new Dialog(ctx);
    dialog.setContentView(R.layout.order_dialog);
    dialog.setTitle(R.string.OrderDialogTitle);

    datetxt = (EditText) dialog.findViewById(R.id.expdateedit);
    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
    Date dat1 = new Date();
    datetxt.setText(sdf.format(dat1));/*from w  w w  . ja va2s.  co m*/
    mYear = dat1.getYear() + 1900;
    mMonth = dat1.getMonth();
    mDay = dat1.getDate();
    final Date dat = new GregorianCalendar(mYear, mMonth, mDay).getTime();

    datetxt.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Log.i(TAG, "Show DatePickerDialog");
            DatePickerDialog dpd = new DatePickerDialog(ctx, mDateSetListener, mYear, mMonth, mDay);
            dpd.show();
        }
    });

    TextView itext = (TextView) dialog.findViewById(R.id.instrtext);
    itext.setText(it.symbol);

    final Spinner aspinner = (Spinner) dialog.findViewById(R.id.acc_spinner);
    List<String> list = new ArrayList<String>(Common.getAccountList());
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(Common.app_ctx,
            android.R.layout.simple_spinner_item, list);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
    aspinner.setAdapter(dataAdapter);

    final EditText pricetxt = (EditText) dialog.findViewById(R.id.priceedit);
    final EditText quanttxt = (EditText) dialog.findViewById(R.id.quantedit);

    final Button buttonpm = (Button) dialog.findViewById(R.id.buttonPriceMinus);
    buttonpm.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                double price = Double.valueOf(pricetxt.getText().toString());
                price -= 0.01;
                if (price < 0)
                    price = 0;
                pricetxt.setText(twoDForm.format(price));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonpp = (Button) dialog.findViewById(R.id.buttonPricePlus);
    buttonpp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                double price = Double.valueOf(pricetxt.getText().toString());
                price += 0.01;
                pricetxt.setText(twoDForm.format(price));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonqm = (Button) dialog.findViewById(R.id.buttonQtyMinus);
    buttonqm.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                long qty = Long.valueOf(quanttxt.getText().toString());
                qty -= 1;
                if (qty < 0)
                    qty = 0;
                quanttxt.setText(String.valueOf(qty));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonqp = (Button) dialog.findViewById(R.id.buttonQtyPlus);
    buttonqp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                long qty = Long.valueOf(quanttxt.getText().toString());
                qty += 1;
                quanttxt.setText(String.valueOf(qty));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final RadioButton bu0 = (RadioButton) dialog.findViewById(R.id.radio0);
    final RadioButton bu1 = (RadioButton) dialog.findViewById(R.id.radio1);

    if (quote != null) {

        // pricetxt.setText(quote.price.toString());
        pricetxt.setText(quote.getPriceS());
        if (quote.qtyBuy > 0) {

            quanttxt.setText(quote.qtyBuy.toString());
            bu1.setChecked(true);
            bu0.setChecked(false);

        } else {

            quanttxt.setText(quote.qtySell.toString());
            bu1.setChecked(false);
            bu0.setChecked(true);

        }
    }

    Button customDialog_Cancel = (Button) dialog.findViewById(R.id.cancelbutt);
    customDialog_Cancel.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            dialog.dismiss();
        }

    });

    Button customDialog_Put = (Button) dialog.findViewById(R.id.putorder);
    customDialog_Put.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            Double price = new Double(0);
            Long qval = new Long(0);

            try {

                price = Double.valueOf(pricetxt.getText().toString());
            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
                return;
            }
            try {

                qval = Long.valueOf(quanttxt.getText().toString());
            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
                return;
            }

            if (dat.compareTo(new GregorianCalendar(mYear, mMonth, mDay).getTime()) > 0) {

                Toast.makeText(ctx, R.string.CorrectDate, Toast.LENGTH_SHORT).show();

                return;

            }

            JSONObject msg = new JSONObject();
            try {

                msg.put("objType", Common.CREATE_REMOVE_ORDER);
                msg.put("time", Calendar.getInstance().getTimeInMillis());
                msg.put("version", Common.PROTOCOL_VERSION);
                msg.put("device", "Android");
                msg.put("instrumId", Long.valueOf(it.id));
                msg.put("price", price);
                msg.put("qty", qval);
                msg.put("ordType", 1);
                msg.put("side", bu0.isChecked() ? 0 : 1);
                msg.put("code", String.valueOf(aspinner.getSelectedItem()));
                msg.put("orderNum", ++ordernum);
                msg.put("action", "CREATE");
                boolean b = (((mYear - 1900) == dat.getYear()) && (mMonth == dat.getMonth())
                        && (mDay == dat.getDate()));
                if (!b)
                    msg.put("expired", String.format("%02d.%02d.%04d", mDay, mMonth + 1, mYear));

                if (isSSL) {

                    //                ? ?:    newOrder-orderNum-instrumId-side-price-qty-code-ordType
                    //               :                  newOrder-16807-20594623-0-1150-13-1027700451-1
                    String forsign = "newOrder-" + ordernum + "-" + msg.getString("instrumId") + "-"
                            + msg.getString("side") + "-"
                            + JSONObject.numberToString(Double.valueOf(msg.getDouble("price"))) + "-"
                            + msg.getString("qty") + "-" + msg.getString("code") + "-"
                            + msg.getString("ordType");
                    byte[] signed = Common.signText(Common.signProfile, forsign.getBytes(), true);
                    String gsign = Base64.encodeToString(signed, Base64.DEFAULT);
                    msg.put("gostSign", gsign);
                }
                mainActivity.writeJSONMsg(msg);

            } catch (Exception e) {

                e.printStackTrace();
                Log.e(TAG, "Error! Cannot create JSON order object", e);
            }

            dialog.dismiss();
        }

    });

    dialog.show();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.FILL_PARENT;
    dialog.getWindow().setAttributes(lp);

}

From source file:com.xperia64.timidityae.SettingsActivity.java

public void setUpNestedScreen(PreferenceScreen preferenceScreen) {
    final Dialog dialog = preferenceScreen.getDialog();

    Toolbar bar;//from   w w w. j  av  a 2  s. c  o m

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        LinearLayout root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent();
        bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);
        bar.setElevation(abElevation);
        root.addView(bar, 0);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        LinearLayout root = (LinearLayout) dialog.findViewById(android.R.id.list).getParent();
        bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);
        root.addView(bar, 0); // insert at top
    } else {
        ViewGroup root = (ViewGroup) dialog.findViewById(android.R.id.content);
        ListView content = (ListView) root.getChildAt(0);

        root.removeAllViews();

        bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);

        int height;
        TypedValue tv = new TypedValue();
        if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) {
            height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
        } else {
            height = bar.getHeight();
        }

        content.setPadding(0, height, 0, 0);

        root.addView(content);
        root.addView(bar);
    }

    bar.setTitle(preferenceScreen.getTitle());

    bar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}

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

/**
 * Set the the values of the date and the time picker of the DateTimePicker
 * dialog/*from   w w w. j  av a 2 s.c  om*/
 * 
 * @param dialog
 *            The Dialog containing the date and the time picker
 * @param cal
 *            The calendar-object to set date and time from
 */
private void setDateAndTimePicker(final Dialog dialog, Calendar cal) {
    DatePicker dp = (DatePicker) dialog.findViewById(R.id.DatePicker);
    TimePicker tp = (TimePicker) dialog.findViewById(R.id.TimePicker);

    dp.updateDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
    tp.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
    tp.setCurrentMinute(cal.get(Calendar.MINUTE));
}

From source file:com.bitants.wally.fragments.MaterialDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (getActivity() != null) {
        final Dialog dialog = new Dialog(getActivity(),
                android.support.v7.appcompat.R.style.Base_Theme_AppCompat_Light_Dialog);
        //                    android.R.style.Theme_DeviceDefault_Light_Dialog);
        dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.setContentView(R.layout.dialog_base_material);
        textViewTitle = (TextView) dialog.findViewById(R.id.dialog_title);
        buttonNegative = (Button) dialog.findViewById(R.id.dialog_button_negative);
        buttonPositive = (Button) dialog.findViewById(R.id.dialog_button_positive);
        scrollView = (ScrollView) dialog.findViewById(R.id.dialog_scrollview);
        viewStub = (ViewStub) dialog.findViewById(R.id.dialog_viewstub);

        setupViews(dialog.getContext());
        hideEmptyViews();//from  w  ww  .jav  a 2s.c  o  m

        if (!isCancelable()) {
            buttonNegative.setVisibility(View.GONE);
        }

        return dialog;
    } else {
        return null;
    }
}