List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:com.adkdevelopment.movieslist.ui.TimeDialog.java
@NonNull @Override//from www .jav a2 s . c o m public Dialog onCreateDialog(Bundle savedInstanceState) { if (getArguments() != null) { mCurrentTime = getArguments().getLong(DialogService.CUR_TIME, System.currentTimeMillis()); } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); @SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.dialog_time, null); Picasso.with(getContext()).load(getString(R.string.dialog_watchlink)) .into((ImageView) dialogView.findViewById(R.id.dialog_image)); ((TextView) dialogView.findViewById(R.id.dialog_time)) .setText(String.format(getString(R.string.dialog_time), Utilities.getFormattedDate(mCurrentTime))); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout builder.setView(dialogView) // Add action buttons .setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { } }); return builder.create(); }
From source file:com.andybotting.tramhunter.activity.HomeActivity.java
/** * Show the about dialog/*www .j a v a 2 s . c o m*/ */ public void showAbout() { // Get the package name String heading = getResources().getText(R.string.app_name).toString(); try { PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0); heading += " v" + pi.versionName + ""; } catch (NameNotFoundException e) { e.printStackTrace(); } // Build alert dialog, using a ContextThemeWrapper for proper theming AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( new ContextThemeWrapper(this, R.style.AlertDialog)); View aboutView = View.inflate(new ContextThemeWrapper(this, R.style.AlertDialog), R.layout.dialog_about, null); dialogBuilder.setTitle(heading); dialogBuilder.setView(aboutView); dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { mPreferenceHelper.setFirstLaunchThisVersion(); } }); dialogBuilder.setCancelable(false); dialogBuilder.setIcon(R.drawable.icon); dialogBuilder.show(); }
From source file:com.aniruddhc.acemusic.player.Dialogs.DeterminateProgressDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();//from w w w. j a v a 2 s. c om dialog = this; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); String title = getArguments().getString("TITLE"); String text = getArguments().getString("TEXT"); View progressView = parentActivity.getLayoutInflater().inflate(R.layout.determinate_progress_dialog, null); progressText = (TextView) progressView.findViewById(R.id.determinate_progress_dialog_text); progressText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); progressText.setPaintFlags(progressText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); progressText.setText(text); progressBar = (ProgressBar) progressView.findViewById(R.id.determinate_progress_dialog_bar); builder.setTitle(title); builder.setView(progressView); return builder.create(); }
From source file:com.andybotting.tubechaser.activity.Home.java
/** * Show about dialog window// w w w . j a v a2s . c om */ public void showAbout() { // Get the package name String heading = getResources().getText(R.string.app_name) + "\n"; try { PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0); heading += "v" + pi.versionName + "\n\n"; } catch (NameNotFoundException e) { e.printStackTrace(); } // Build alert dialog AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.setTitle(heading); View aboutView = getLayoutInflater().inflate(R.layout.dialog_about, null); dialogBuilder.setView(aboutView); dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Set first launch flag in DB mPreferenceHelper.setFirstLaunchThisVersion(); } }); dialogBuilder.setCancelable(false); dialogBuilder.setIcon(R.drawable.appicon); dialogBuilder.show(); }
From source file:eu.codeplumbers.cosi.wizards.firstrun.ConnectFragment.java
private void showGiveDevicePasswordDialog() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle("Register your device"); alertDialog.setMessage("Your device is already registered\n Please type your device token"); final EditText input = new EditText(getActivity()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); input.setLayoutParams(lp);/*from ww w . j a v a2s .co m*/ alertDialog.setView(input); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String password = input.getText().toString(); if (!password.isEmpty()) { final JSONObject permissionJson = new JSONObject(); final JSONObject desc = new JSONObject(); try { Device device = new Device(); device.setUrl(mUrl.getText().toString()); device.setLogin(mDeviceName.getText().toString()); device.setPassword(password); desc.put("description", "sync all my cozy data"); permissionJson.put("All", desc); device.setPermissions(permissionJson.toString()); device.setFirstSyncDone(false); device.setSyncCalls(false); device.setSyncContacts(false); device.setSyncFiles(false); device.setSyncNotes(false); device.save(); onRegisterSuccess(device); } catch (JSONException e) { e.printStackTrace(); } } else { input.setError("Your device token can not be empty!"); } } }); alertDialog.show(); }
From source file:jp.watnow.plugins.dialog.Notification.java
/** * Builds and shows a native Android prompt dialog with given title, message, buttons. * This dialog only shows up to 3 buttons. Any labels after that will be ignored. * The following results are returned to the JavaScript callback identified by callbackId: * buttonIndex Index number of the button selected * input1 The text entered in the prompt dialog box * * @param message The message the dialog should display * @param title The title of the dialog * @param buttonLabels A comma separated list of button labels (Up to 3 buttons) * @param callbackContext The callback context. *///w w w . ja v a2 s .c om public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels, final String defaultText, final String dialogType, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { final EditText promptInput = new EditText(cordova.getActivity()); promptInput.setHint(defaultText); Log.d("DialogPlugin", dialogType); if (dialogType.equals(INPUT_SECURE)) { promptInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); dlg.setView(promptInput); final JSONObject result = new JSONObject(); // First button if (buttonLabels.length() > 0) { try { dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 1); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } // Second button if (buttonLabels.length() > 1) { try { dlg.setNeutralButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 2); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } // Third button if (buttonLabels.length() > 2) { try { dlg.setPositiveButton(buttonLabels.getString(2), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 3); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); try { result.put("buttonIndex", 0); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); changeTextDirection(dlg); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.cricketkorner.cricket.VitamioListActivity.java
private void ListFunction() { listView = (ListView) findViewById(R.id.listView); //copying array for (int i = 0; i < Singleton.getInstance().getChannelList().size(); i++) { title.add(Singleton.getInstance().getChannelList().get(i).getChannelName()); desc.add("Long Press This Channel To Report, Id: " + Singleton.getInstance().getChannelList().get(i).getChannelId()); thumb.add(R.drawable.ic_launcher); }//from w ww.j a v a 2s . co m listView.setAdapter(new VersionAdapter(VitamioListActivity.this)); listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) { AlertDialog.Builder alert = new AlertDialog.Builder(VitamioListActivity.this); alert.setTitle("Report Broken Link"); alert.setMessage("Message: (Channel not working?)"); // Set an EditText view to get user input final EditText input = new EditText(VitamioListActivity.this); alert.setView(input); alert.setPositiveButton("Submit", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); if (isNetworkAvailable()) { new ReportFeedback().execute("http://yoururl.com/LiveStreaming/reportFeedback.php", value, Singleton.getInstance().getChannelList().get(position).getChannelId()); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); return false; } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { int pos = arg2; LayoutInflater layoutInflator = getLayoutInflater(); View layout = layoutInflator.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.toast_layout_root)); ImageView iv = (ImageView) layout.findViewById(R.id.toast_iv); TextView tv = (TextView) layout.findViewById(R.id.toast_tv); iv.setBackgroundResource(thumb.get(pos)); tv.setText(title.get(pos)); Intent intent = new Intent(VitamioListActivity.this, VideoViewDemo.class); intent.putExtra("path", Singleton.getInstance().getChannelList().get(pos).getChannelPath()); startAppAd.onBackPressed(); startActivity(intent); } }); }
From source file:com.coincide.alphafitness.ui.Activity_Main.java
public boolean optionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case android.R.id.home: getFragmentManager().popBackStackImmediate(); break;/*from www . ja va 2s . c o m*/ case R.id.action_settings: getFragmentManager().beginTransaction().replace(android.R.id.content, new Fragment_Settings()) .addToBackStack(null).commit(); break; case R.id.action_leaderboard: case R.id.action_achievements: AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle("Google services required"); builder2.setMessage("This feature is not available on the F-Droid version of the app"); builder2.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder2.create().show(); break; case R.id.action_faq: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://j4velin.de/faq/index.php?app=pm")) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); break; case R.id.action_about: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.about); TextView tv = new TextView(this); tv.setPadding(10, 10, 10, 10); tv.setText(R.string.about_text_links); try { tv.append(getString(R.string.about_app_version, getPackageManager().getPackageInfo(getPackageName(), 0).versionName)); } catch (NameNotFoundException e1) { // should not happen as the app is definitely installed when // seeing the dialog e1.printStackTrace(); } tv.setMovementMethod(LinkMovementMethod.getInstance()); builder.setView(tv); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); break; } return true; }
From source file:com.codeskraps.sbrowser.home.SBrowserActivity.java
public void onClick(View v) { switch (v.getId()) { case R.id.btnWww: final AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(getResources().getString(R.string.alertHttpTitle)); alert.setMessage(getResources().getString(R.string.alertHttpSummary)); final EditText input = new EditText(this); String url = webView == null ? null : webView.getUrl(); if (url != null) input.setText(url);//from w w w. ja v a2s .co m alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString().trim(); if (value.startsWith("http")) webView.loadUrl(value); else webView.loadUrl("http://" + value); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alert.show(); break; case R.id.btnHome: webView.loadUrl(sBrowserData.getetxtHome()); break; case R.id.btnRight: webView.goForward(); break; case R.id.btnRefresh: if (wF != null && wF.isReloading() == false) { webView.reload(); } else { webView.stopLoading(); } break; case R.id.btnSearch: doSearch(); break; case R.id.btnMenu: Log.v(TAG, "Menu pressed"); openOptionsMenu(); break; } }
From source file:com.example.sujit.customerapp.Get_Taxi.java
private void showProfile() { LayoutInflater li = LayoutInflater.from(this); //Creating a view to get the dialog box View confirmDialog = li.inflate(R.layout.dialog_profile, null); buttonCall = (AppCompatButton) confirmDialog.findViewById(R.id.buttonCall); textViewName1 = (TextView) confirmDialog.findViewById(R.id.textViewName1); textViewLicenseNo1 = (TextView) confirmDialog.findViewById(R.id.textViewLicenseNo1); textViewAddress1 = (TextView) confirmDialog.findViewById(R.id.textViewAddress1); textViewMobile1 = (TextView) confirmDialog.findViewById(R.id.textViewMobile1); textViewTaxiNo1 = (TextView) confirmDialog.findViewById(R.id.textViewTaxiNo1); textusername1 = (TextView) confirmDialog.findViewById(R.id.textusername1); AlertDialog.Builder alert = new AlertDialog.Builder(this); //Adding our dialog box to the view of alert dialog alert.setView(confirmDialog); //Creating an alert dialog final AlertDialog alertDialog = alert.create(); //Displaying the alert dialog alertDialog.show();/*from w ww . j a va 2 s. c o m*/ // RequestQueue requestQueue = Volley.newRequestQueue(Get_Taxi.this); //Yesbata mobile no pani POST ma pathauna parcha final ProgressDialog loading = ProgressDialog.show(this, "Getting Nearest Driver", "Please wait...", false, false); StringRequest stringRequest = new StringRequest(Request.Method.POST, "http://6e1e7877.ngrok.io/findmeataxi", new Response.Listener<String>() { @Override public void onResponse(String response) { loading.dismiss(); Log.d("FINDMEATAXI", response); try { JSONObject jsonObject = new JSONObject(response); JSONArray jsonArray = jsonObject.getJSONArray("driver"); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject1 = jsonArray.getJSONObject(i); String username = jsonObject1.getString("username"); String taxi_number = jsonObject1.getString("taxi_number"); String license_number = jsonObject1.getString("license_number"); String mobile_number = jsonObject1.getString("mobile_number"); String full_name = jsonObject1.getString("full_name"); String address = jsonObject1.getString("address"); textusername1.setText(username); textViewTaxiNo1.setText(taxi_number); textViewLicenseNo1.setText(license_number); textViewMobile1.setText(mobile_number); textViewName1.setText(full_name); textViewAddress1.setText(address); } } catch (JSONException e) { e.printStackTrace(); loading.dismiss(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { loading.dismiss(); Log.d("Volley Error Response:", error.toString()); } }) { @Override protected Map<String, String> getParams() { SharedPreferences sharedPreferences = getSharedPreferences("LoggedInUser", MODE_PRIVATE); String phnNo = sharedPreferences.getString("phoneNo", ""); Map<String, String> params = new HashMap<>(); params.put("latitude", String.valueOf(currentLatitude)); params.put("longitude", String.valueOf(currentLongitude)); params.put("mobile_number", phnNo); return params; } }; MySingleton.getInstance(getApplicationContext()).addToRequestQueue(stringRequest); buttonCall.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { alertDialog.dismiss(); SendInfo(textusername1.getText().toString()); // callDriver(); } }); }