List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:com.dsi.ant.antplus.pluginsampler.watchdownloader.Dialog_WatchData.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Data for: " + deviceData.getDisplayName()); // Get the layout inflater final LayoutInflater inflater = getActivity().getLayoutInflater(); final View detailsView = inflater.inflate(R.layout.dialog_watchdata, null); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout builder.setView(detailsView); // Add action buttons builder.setPositiveButton("Close", null); linearLayout_FitDataView = (LinearLayout) detailsView.findViewById(R.id.linearLayout_DataCards); FileIdMesgListener fileIdMesgListener = new FileIdMesgListener() { @Override/* w ww . j a va 2 s . com*/ public void onMesg(final FileIdMesg mesg) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { layoutControllerList .add(new LayoutController_FileId(inflater, linearLayout_FitDataView, mesg)); } }); } }; ActivityMesgListener activityMesgListener = new ActivityMesgListener() { @Override public void onMesg(final ActivityMesg mesg) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { layoutControllerList .add(new LayoutController_Activity(inflater, linearLayout_FitDataView, mesg)); } }); } }; SessionMesgListener sessionMesgListener = new SessionMesgListener() { @Override public void onMesg(final SessionMesg mesg) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { layoutControllerList .add(new LayoutController_Session(inflater, linearLayout_FitDataView, mesg)); } }); } }; MesgBroadcaster mesgBroadcaster; // If we have downloaded fit file to display, hides the no activities available text view if (!fitFileList.isEmpty()) { TextView textview = (TextView) detailsView.findViewById(R.id.textView_no_data_page); textview.setVisibility(TextView.INVISIBLE); } for (final FitFile downloadedFitFile : fitFileList) try { mesgBroadcaster = new MesgBroadcaster(); mesgBroadcaster.addListener(activityMesgListener); mesgBroadcaster.addListener(fileIdMesgListener); mesgBroadcaster.addListener(sessionMesgListener); Log.e("WatchDownloaderSampler", "Begin decoding file"); mesgBroadcaster.run(downloadedFitFile.getInputStream()); Log.e("WatchDownloaderSampler", "End decoding file"); } catch (FitRuntimeException e) { Log.e("WatchDownloaderSampler", "Error decoding FIT file: " + e.getMessage()); getActivity().runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getActivity(), "Error decoding FIT file", Toast.LENGTH_LONG).show(); } }); } return builder.create(); }
From source file:edu.missouri.bas.activities.AdminManageActivity.java
private Dialog AdminPinDialog(Context context) { LayoutInflater inflater = LayoutInflater.from(this); final View textEntryView = inflater.inflate(R.layout.pin_login, null); alert_text = (TextView) textEntryView.findViewById(R.id.pin_text); alert_text.setText("Please input PIN for administrator"); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false);/*ww w. ja va 2 s.c om*/ builder.setTitle("Verify Admin PIN"); builder.setView(textEntryView); //builder.setMessage("Please input PIN for administrator"); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { //check networking adminPin = (EditText) textEntryView.findViewById(R.id.pin_edit); String AdPin = adminPin.getText().toString(); Log.d(TAG, "get from edittext is " + AdPin); HttpPost request = new HttpPost( "http://dslsrv8.cs.missouri.edu/~rs79c/Server/Crt/validateUser.php"); List<NameValuePair> params = new ArrayList<NameValuePair>(); //file_name params.add(new BasicNameValuePair("userID", "0000")); //function params.add(new BasicNameValuePair("pre", "1")); //data params.add(new BasicNameValuePair("password", AdPin)); try { request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); HttpResponse response = new DefaultHttpClient().execute(request); if (response.getStatusLine().getStatusCode() == 200) { String result = EntityUtils.toString(response.getEntity()); Log.d("~~~~~~~~~~http post result", result); if (result.equals("AdminIsChecked")) { //do nothing //setResult(8); } else if (result.equals("AdminPinIsInvalid")) { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast toast = Toast.makeText(getApplicationContext(), "Admin PIN is wrong, exit! Please try again.", Toast.LENGTH_SHORT); toast.show(); //set return code /* if(shp.getString(ASID, "").equals("")){ setResult(9); }else{ setResult(Activity.RESULT_CANCELED); }*/ //setResult(9); finish(); } else { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast toast = Toast.makeText(getApplicationContext(), "Verify failed. Please try again.", Toast.LENGTH_SHORT); toast.show(); //set return code /* if(shp.getString(ASID, "").equals("")){ setResult(9); }else{ setResult(Activity.RESULT_CANCELED); }*/ finish(); } } } catch (Exception e) { // TODO Auto-generated catch block imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast toast = Toast.makeText(getApplicationContext(), "Failed. Please try again, with network connection.", Toast.LENGTH_SHORT); toast.show(); //set return code /* if(shp.getString(ASID, "").equals("")){ setResult(9); }else{ setResult(Activity.RESULT_CANCELED); }*/ finish(); e.printStackTrace(); } } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); //set return code /* if(shp.getString(ASID, "").equals("")){ setResult(9); }else{ setResult(Activity.RESULT_CANCELED); }*/ setResult(9); finish(); } }); return builder.create(); }
From source file:com.rainmakerlabs.bleepsample.BleepService.java
private void showAlertDialog(String title, String msg, String posText, DialogInterface.OnClickListener posFunc, String negText, DialogInterface.OnClickListener negFunc, EditText input) { if (BLEalert != null && BLEalert.isShowing()) { BLEalert.cancel();//w w w. j a va 2 s . co m } //if (BLEalert == null || !BLEalert.isShowing()) { if (title == null) title = ""; if (msg == null) msg = ""; if (title.equalsIgnoreCase("") && msg.equalsIgnoreCase("")) return; AlertDialog.Builder builder = new AlertDialog.Builder(BleepActivity.currentBleepActivity); builder.setTitle(title); builder.setMessage(msg); if (input != null) builder.setView(input); if (posText != null && !posText.equalsIgnoreCase("")) builder.setPositiveButton(posText, posFunc); if (negText != null && !negText.equalsIgnoreCase("")) builder.setNegativeButton(negText, negFunc); BLEalert = builder.create(); BLEalert.show(); //} }
From source file:de.awisus.refugeeaidleipzig.views.login.FragmentAnmelden.java
/** * Called when this dialogue is created; Android-specific * Inflates the layout, initialises text field and spinner, initialises the spinner adapter to * show up accommodations and sets the dialogue buttons * * @param savedInstanceState Bundle of saved instance state * @return dialogue created by the AlertDialog.Builder *///from www .j a va2s.c om @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Button btAnmelden, btNeu; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_anmelden, null); warnungID = R.string.warnung_anmelden; etName = (EditText) view.findViewById(R.id.etName); etPasswort = (EditText) view.findViewById(R.id.etPassword); btAnmelden = (Button) view.findViewById(R.id.btAnmelden); btNeu = (Button) view.findViewById(R.id.btNeu); btAnmelden.setOnClickListener(this); btNeu.setOnClickListener(this); builder.setView(view); Dialog dialog = builder.create(); dialog.setTitle(R.string.titel_login); dialog.setCancelable(false); dialog.setCanceledOnTouchOutside(false); return dialog; }
From source file:com.nbos.phonebook.sync.authenticator.AuthenticatorActivity.java
void createAccountWithFbId() { mPrefs = getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = mPrefs.edit(); editor.putString("access_token", facebook.getAccessToken()); editor.putLong("access_expires", facebook.getAccessExpires()); editor.commit();/*w w w . java 2 s. co m*/ String access_token = mPrefs.getString("access_token", null); long expires = mPrefs.getLong("access_expires", 0); if (access_token != null) { facebook.setAccessToken(access_token); } if (expires != 0) { facebook.setAccessExpires(expires); } /* * Only call authorize if the access_token has expired. */ if (facebook.isSessionValid()) { Log.i(tag, "Session is valid"); JSONObject json; try { json = Util.parseJson(facebook.request("me", new Bundle())); Log.i(tag, "json: " + json); fbId = json.getString("id"); String username = json.getString("id"); JSONArray existingUser = new Cloud(getApplicationContext(), fbId, null).findExistingFbUser(fbId, countryCode + mPhone); Log.i(tag, "existingUser: " + existingUser.getString(0)); LayoutInflater factory = LayoutInflater.from(this); textEntryView = factory.inflate(R.layout.facebook_email_layout, null); TextView fbUsername = (TextView) textEntryView.findViewById(R.id.facebookLogin_email); TextView fbPassword = (TextView) textEntryView.findViewById(R.id.facebookLogin_password); Button fbAccountButton = (Button) textEntryView.findViewById(R.id.facebookLogin); if (existingUser.getString(0).trim().length() == 0) { Log.i(tag, "email: " + Text.isEmail(username)); if (!(Text.isEmail(username))) { AlertDialog.Builder newBuilder = new AlertDialog.Builder(this); newBuilder.setTitle("FbLogin to Phonebook"); newBuilder.setView(textEntryView); Button existingFbAccount = (Button) textEntryView .findViewById(R.id.existingAccountfacebookLogin); existingFbAccount.setVisibility(View.GONE); AlertDialog newAlert = newBuilder.create(); newAlert.show(); } } else { fbAccountButton.setVisibility(View.GONE); fbUsername.setText(existingUser.getString(0)); fbUsername.setEnabled(false); fbPassword.requestFocus(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("FbLogin to Phonebook"); builder.setView(textEntryView); AlertDialog alert = builder.create(); alert.show(); } //mPhone = mPhoneEdit.getText().toString(); //new Cloud(getApplicationContext(), userId, userId).loginWithFacebook(countryCode + mPhone); /*mUsername = userName; mPassword = userId;*/ //finishLogin(); // mUsernameEdit.setText(userName); // mPasswordEdit.setText(userId); Log.i(tag, "userName: " + username + " userId: " + fbId); Log.i(tag, "response:" + json); } catch (Exception e1) { Log.e(tag, "Exception logging on with Facebook: " + e1); e1.printStackTrace(); } catch (FacebookError e) { Log.e(tag, "Facebook error logging on with Facebook: " + e); e.printStackTrace(); } } }
From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditClaimActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.cmenu_dlist_delete: ClaimListController.removeDestination(destAdaptor.getItem(info.position), theClaim); destAdaptor.notifyDataSetChanged(); return true; case R.id.cmenu_dlist_edit: //show a dialog for editing destinations final EditText enterLocation = new EditText(this); final EditText enterReason = new EditText(this); enterLocation.setText(destAdaptor.getItem(info.position).getLocation()); enterReason.setText(destAdaptor.getItem(info.position).getReason()); enterLocation.setHint("Enter location"); enterReason.setHint("Enter reason"); LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(enterLocation); linearLayout.addView(enterReason); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setView(linearLayout); alert.setPositiveButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { destAdaptor.getItem(info.position).setLocation(enterLocation.getText().toString()); destAdaptor.getItem(info.position).setReason(enterReason.getText().toString()); destAdaptor.notifyDataSetChanged(); }/* w w w . ja v a 2 s.c o m*/ }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alert.show(); return true; case R.id.cmenu_dlist_geolocation: adaptorPos = info.position; AlertDialog.Builder alertGl = new AlertDialog.Builder(this); alertGl.setPositiveButton("GPS", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (GeoLocationController.checkGPSEnabled()) { GeoLocationController.setDestinationGeoLocationGPS(destAdaptor.getItem(info.position)); destAdaptor.notifyDataSetChanged(); } } }); alertGl.setNegativeButton("Map", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Open map view \ Intent intent = GeoLocationController.pickLocationIntent(EditClaimActivity.this); startActivityForResult(intent, GET_GEOLOCATION_CODE); } }); alertGl.show(); return true; case R.id.cmenu_delete_tag: ClaimListController.removeTag(theClaim, tagAdaptor.getItem(info.position)); tagAdaptor.notifyDataSetChanged(); return true; case R.id.cmenu_rename_tag: //create a Alert dialog for editing tag name final TextView enterTag = new AutoCompleteTextView(this); enterTag.setHint("Enter tag"); AlertDialog.Builder alertTag = new AlertDialog.Builder(this); alertTag.setView(enterTag); alertTag.setPositiveButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { tagAdaptor.getItem(info.position).setName(enterTag.getText().toString()); tagAdaptor.notifyDataSetChanged(); } }); alertTag.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alertTag.show(); return true; default: return super.onContextItemSelected(item); } }
From source file:com.emuneee.nctrafficcams.ui.activities.MainActivity.java
/** * Displays the end user license agreement at startup *//*from ww w. j av a 2 s . c om*/ private void showEula() { AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.eula_dialog, null); final Dialog dialog; builder.setCancelable(false); builder.setView(view); builder.setTitle(R.string.eula_title); builder.setPositiveButton(R.string.agree, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); Editor editor = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit(); editor.putBoolean(Constants.PREF_EULA_ACCEPTED, true); editor.commit(); editor = getPreferences(Context.MODE_PRIVATE).edit(); editor.putBoolean(Constants.PREF_TRAFFIC_CAMS_INIT, true); editor.commit(); mGetLatestCamerasTask.execute(); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); Editor editor = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit(); editor.putBoolean(Constants.PREF_EULA_ACCEPTED, false); editor.commit(); MainActivity.this.finish(); } }); dialog = builder.create(); // load the eula from assets WebView wv = (WebView) view.findViewById(R.id.web_view_eula); wv.loadUrl("file:///android_asset/eula.htm"); dialog.show(); }
From source file:com.anton.gavel.PersonalInfoDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); dialogView = inflater.inflate(R.layout.dialog_personal_info, null); Spinner spinner = (Spinner) dialogView.findViewById(R.id.personal_cities_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.cities, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);// w w w .j a v a 2 s . c om builder.setView(dialogView).setTitle("Personal Information") .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { mListener.onDialogPositiveClick(PersonalInfoDialogFragment.this); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { PersonalInfoDialogFragment.this.getDialog().cancel(); } }); populatePersonalInfo(); return builder.create(); }
From source file:org.yaoha.YaohaActivity.java
private void openFavMenu(final ImageButton btn, final TextView tv) { AlertDialog.Builder alert = new AlertDialog.Builder(this); final EditText input = new EditText(this); alert.setTitle("Adding favorite"); alert.setMessage("Enter your favorite search"); alert.setView(input); alert.setPositiveButton("Set", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { final Editor edit = prefs.edit(); String tmp = ""; tv.setText(input.getText()); btn.setImageResource(R.drawable.placeholder_logo); if (btn.getId() == button_favorite_1.getId()) { tmp = "saved_fav_1_text"; } else if (btn.getId() == button_favorite_2.getId()) { tmp = "saved_fav_2_text"; } else if (btn.getId() == button_favorite_3.getId()) { tmp = "saved_fav_3_text"; } else if (btn.getId() == button_favorite_4.getId()) { tmp = "saved_fav_4_text"; } else if (btn.getId() == button_favorite_5.getId()) { tmp = "saved_fav_5_text"; } else if (btn.getId() == button_favorite_6.getId()) { tmp = "saved_fav_6_text"; }/* www . j a v a 2 s.c om*/ edit.putString(tmp, input.getText().toString()); edit.commit(); //TODO add method to catch pre-defined store-icons } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); }
From source file:com.vuze.android.remote.AndroidUtils.java
/** * Creates an AlertDialog.Builder that has the proper theme for Gingerbread *//*from ww w . jav a 2 s. co m*/ public static AndroidUtils.AlertDialogBuilder createAlertDialogBuilder(Activity activity, int resource) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); // Not sure if we need this anymore, but once upon a time, pre-honeycomb // (2.x) had dialog color issues if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) { builder.setInverseBackgroundForced(true); } View view = View.inflate(activity, resource, null); builder.setView(view); return new AndroidUtils.AlertDialogBuilder(view, builder); }