List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:com.esri.squadleader.view.AddLayerFromWebDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (null != listener) { final Activity activity = getActivity(); LayoutInflater inflater = activity.getLayoutInflater(); AlertDialog.Builder builder = new AlertDialog.Builder(activity); final View inflatedView = inflater.inflate(R.layout.add_layer_from_web, null); builder.setView(inflatedView); builder.setTitle(getString(R.string.add_layer_from_web)); builder.setNegativeButton(R.string.cancel, null); builder.setPositiveButton(R.string.add_layer, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { final boolean useAsBasemap; boolean _useAsBasemap = false; View checkboxView = inflatedView.findViewById(R.id.checkBox_basemap); if (null != checkboxView && checkboxView instanceof CheckBox) { _useAsBasemap = ((CheckBox) checkboxView).isChecked(); }// w w w . jav a2 s . c o m useAsBasemap = _useAsBasemap; View serviceUrlView = inflatedView.findViewById(R.id.editText_serviceUrl); if (null != serviceUrlView && serviceUrlView instanceof EditText) { final String urlString = ((EditText) serviceUrlView).getText().toString(); addLayer(useAsBasemap, urlString); } } }); return builder.create(); } else { return null; } }
From source file:com.baasbox.android.samples.aloa.activities.CreateChannelFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final EditText input = new EditText(getActivity()); builder.setTitle(getString(R.string.create_channel)); builder.setMessage(getString(R.string.create_channel_message)); builder.setView(input); final DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override//from ww w. ja v a 2 s . co m public void onClick(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { String ch = input.getText().toString(); if (listener != null && !TextUtils.isEmpty(ch)) { listener.onTargetSelected(ch, true); } } } }; builder.setPositiveButton(android.R.string.ok, clickListener); builder.setNegativeButton(android.R.string.cancel, clickListener); return builder.create(); }
From source file:com.androzic.waypoint.CoordinatesReceived.java
@NonNull @SuppressLint("InflateParams") @Override//from ww w. j av a 2s .c o m public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.information_name)); View view = getActivity().getLayoutInflater().inflate(R.layout.dlg_coordinates_received, null); builder.setView(view); builder.setPositiveButton(R.string.menu_visible, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Androzic application = Androzic.getApplication(); application.ensureVisible(lat, lon); CoordinatesReceived.this.dismiss(); } }); Bundle args = getArguments(); String title = args.getString("title"); String sender = args.getString("sender"); lat = args.getDouble("lat"); lon = args.getDouble("lon"); if (!"".equals(title)) builder.setTitle(title); else builder.setTitle(R.string.coordinates_name); Androzic application = Androzic.getApplication(); double[] ll = application.getLocation(); ((TextView) view.findViewById(R.id.message)).setText(getString(R.string.new_coordinates, sender)); String coords = StringFormatter.coordinates(" ", lat, lon); ((TextView) view.findViewById(R.id.coordinates)).setText(coords); double dist = Geo.distance(ll[0], ll[1], lat, lon); double bearing = Geo.bearing(ll[0], ll[1], lat, lon); bearing = application.fixDeclination(bearing); String distance = StringFormatter.distanceH(dist) + " " + StringFormatter.angleH(bearing); ((TextView) view.findViewById(R.id.distance)).setText(distance); return builder.create(); }
From source file:com.androzic.route.RouteStart.java
@SuppressLint("InflateParams") @Override/* w ww. j a v a 2 s .c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.routestart_name)); final View view = getActivity().getLayoutInflater().inflate(R.layout.act_route_start, null); builder.setView(view); builder.setPositiveButton(R.string.navigate, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { RadioButton forward = (RadioButton) view.findViewById(R.id.forward); int dir = forward.isChecked() ? NavigationService.DIRECTION_FORWARD : NavigationService.DIRECTION_REVERSE; routeActionsCallback.onRouteNavigate(route, dir, -1); dismiss(); } }); updateRouteInfo(view); return builder.create(); }
From source file:fi.mikuz.boarder.gui.internet.Settings.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.internet_settings); this.setVolumeControlStream(AudioManager.STREAM_MUSIC); @SuppressWarnings("unchecked") HashMap<String, String> lastSession = (HashMap<String, String>) getIntent() .getSerializableExtra(InternetMenu.LOGIN_KEY); try {//from w ww. ja v a 2 s. c om mUserId = lastSession.get(InternetMenu.USER_ID_KEY); mSessionToken = lastSession.get(InternetMenu.SESSION_TOKEN_KEY); } catch (NullPointerException e) { Toast.makeText(Settings.this, "Please login", Toast.LENGTH_LONG).show(); Settings.this.finish(); } Button changePassword = (Button) findViewById(R.id.change_password); changePassword.setOnClickListener(new OnClickListener() { public void onClick(View v) { LayoutInflater inflater = (LayoutInflater) Settings.this.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.internet_settings_alert_change_password, (ViewGroup) findViewById(R.id.alert_settings_root)); final EditText oldPasswordInput = (EditText) layout.findViewById(R.id.oldPasswordInput); final EditText newPassword1Input = (EditText) layout.findViewById(R.id.newPassword1Input); final EditText newPassword2Input = (EditText) layout.findViewById(R.id.newPassword2Input); Button submitButton = (Button) layout.findViewById(R.id.submitButton); AlertDialog.Builder builder = new AlertDialog.Builder(Settings.this); builder.setView(layout); builder.setTitle("Change password"); submitButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { String oldPasswordText = oldPasswordInput.getText().toString(); String newPassword1Text = newPassword1Input.getText().toString(); String newPassword2Text = newPassword2Input.getText().toString(); if (!newPassword1Text.equals(newPassword2Text)) { Toast.makeText(Settings.this, "New passwords don't match", Toast.LENGTH_LONG).show(); } else if (newPassword1Text.length() < 6) { Toast.makeText(Settings.this, "Password length must be at least 6 characters", Toast.LENGTH_LONG).show(); } else { try { mWaitDialog = new TimeoutProgressDialog(Settings.this, "Waiting for response", TAG, false); HashMap<String, String> sendList = new HashMap<String, String>(); sendList.put(InternetMenu.PASSWORD_KEY, Security.passwordHash(newPassword1Text)); sendList.put(InternetMenu.OLD_PASSWORD_KEY, Security.passwordHash(oldPasswordText)); sendList.put(InternetMenu.USER_ID_KEY, mUserId); sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken); new ConnectionManager(Settings.this, InternetMenu.mChangePasswordURL, sendList); } catch (NoSuchAlgorithmException e) { mWaitDialog.dismiss(); String msg = "Couldn't make md5 hash"; Toast.makeText(Settings.this, msg, Toast.LENGTH_LONG).show(); Log.e(TAG, msg, e); } } } }); builder.show(); } }); Button changeEmail = (Button) findViewById(R.id.change_email); changeEmail.setOnClickListener(new OnClickListener() { public void onClick(View v) { LayoutInflater inflater = (LayoutInflater) Settings.this.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.internet_settings_alert_change_email, (ViewGroup) findViewById(R.id.alert_settings_root)); final EditText passwordInput = (EditText) layout.findViewById(R.id.passwordInput); final EditText newEmailInput = (EditText) layout.findViewById(R.id.newEmailInput); Button submitButton = (Button) layout.findViewById(R.id.submitButton); AlertDialog.Builder builder = new AlertDialog.Builder(Settings.this); builder.setView(layout); builder.setTitle("Change email"); submitButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { String passwordText = passwordInput.getText().toString(); String newEmailText = newEmailInput.getText().toString(); try { mWaitDialog = new TimeoutProgressDialog(Settings.this, "Waiting for response", TAG, false); HashMap<String, String> sendList = new HashMap<String, String>(); sendList.put(InternetMenu.PASSWORD_KEY, Security.passwordHash(passwordText)); sendList.put(InternetMenu.EMAIL_KEY, newEmailText); sendList.put(InternetMenu.USER_ID_KEY, mUserId); sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken); new ConnectionManager(Settings.this, InternetMenu.mChangeEmailURL, sendList); } catch (NoSuchAlgorithmException e) { mWaitDialog.dismiss(); String msg = "Couldn't make md5 hash"; Toast.makeText(Settings.this, msg, Toast.LENGTH_LONG).show(); Log.e(TAG, msg, e); } } }); builder.show(); } }); }
From source file:com.daiv.android.twitter.listeners.InteractionClickListener.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { HoloTextView title = (HoloTextView) view.findViewById(R.id.title); String mTitle = title.getText().toString(); HoloTextView text = (HoloTextView) view.findViewById(R.id.text); String mText = text.getText().toString(); // get the datasource ready to read/write InteractionsDataSource data = InteractionsDataSource.getInstance(context); if (mTitle.contains(context.getResources().getString(R.string.mentioned_by))) { // this is a mention if (MainDrawerArrayAdapter.current < 3) { new Handler().postDelayed(new Runnable() { @Override//w w w . j av a2 s.co m public void run() { try { drawer.closeDrawer(Gravity.END); } catch (Exception e) { // landscape mode } } }, 300); viewPager.setCurrentItem((mentionsPage), true); } else { final int pos = i; try { drawer.closeDrawer(Gravity.END); } catch (Exception e) { // landscape mode } new Thread(new Runnable() { @Override public void run() { Intent intent = new Intent(context, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); intent.putExtra("page_to_open", mentionsPage); intent.putExtra("from_drawer", true); sharedPreferences.edit().putBoolean("should_refresh", false).commit(); try { Thread.sleep(400); } catch (Exception e) { } try { context.startActivity(intent); ((Activity) context).overridePendingTransition(0, 0); ((Activity) context).finish(); } catch (Exception e) { e.printStackTrace(); } } }).start(); } } else if (mTitle.contains(context.getResources().getString(R.string.retweeted)) || mTitle.contains(context.getResources().getString(R.string.favorited)) || mTitle.contains(context.getResources().getString(R.string.quoted)) || mTitle.contains(context.getResources().getString(R.string.new_favorites)) || mTitle.contains(context.getResources().getString(R.string.new_retweets)) || mTitle.contains(context.getResources().getString(R.string.new_quotes))) { // it is a retweet or favorite try { drawer.closeDrawer(Gravity.END); } catch (Exception e) { // landscape mode } // open up the dialog with the users that retweeted it final String[] fItems = data .getUsers(sharedPreferences.getInt("current_account", 1), i, DrawerActivity.oldInteractions.getText().toString() .equals(context.getResources().getString(R.string.old_interactions))) .split(" "); LayoutInflater factory = LayoutInflater.from(context); View content = factory.inflate(R.layout.interaction_dialog, null); TextView textView = (TextView) content.findViewById(R.id.text); textView.setText(mText); ListView lv = (ListView) content.findViewById(R.id.list); lv.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_selectable_list_item, fItems)); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setView(content); AlertDialog alert = builder.create(); alert.show(); } else if (mTitle.contains(context.getResources().getString(R.string.followed))) { // someone new followed you try { drawer.closeDrawer(Gravity.END); } catch (Exception e) { // landscape mode } // a new follower, open up the followers profile String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" ")); } else if (mTitle.contains(context.getResources().getString(R.string.tweeted))) { try { drawer.closeDrawer(Gravity.END); } catch (Exception e) { // landscape mode } // a new follower, open up the followers profile String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" ")); } // mark it read in the sql database data.markRead(sharedPreferences.getInt("current_account", 1), i); // tell the system to refresh the notifications when the user opens the drawer again sharedPreferences.edit().putBoolean("new_notification", true).commit(); }
From source file:com.example.dididoit.app.NewItemDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // build the dialog and set up button click handlers AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); // inflate and set the layout for the dialog // pass in null for the parent view because it's going in the dialog layout builder.setView(inflater.inflate(R.layout.dialog_new_item, null)) .setPositiveButton(R.string.done, new DialogInterface.OnClickListener() { @Override// www . j a va 2 s . co m public void onClick(DialogInterface dialog, int id) { // send positive button event back to host activity mListener.onDialogDoneClick(NewItemDialogFragment.this); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // send negative button event back to host activity mListener.onDialogCancelClick(NewItemDialogFragment.this); } }); return builder.create(); }
From source file:com.androzic.GPSInfo.java
@SuppressLint("InflateParams") @Override//w w w .j a v a 2 s . co m public Dialog onCreateDialog(Bundle savedInstanceState) { shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.information_name)); View view = getActivity().getLayoutInflater().inflate(R.layout.dlg_gps_info, null); builder.setView(view); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { GPSInfo.this.dismiss(); } }); builder.setNeutralButton(R.string.update_almanac, updateOnClickListener); satsValue = (TextView) view.findViewById(R.id.sats); lastfixValue = (TextView) view.findViewById(R.id.lastfix); accuracyValue = (TextView) view.findViewById(R.id.accuracy); hdopValue = (TextView) view.findViewById(R.id.hdop); vdopValue = (TextView) view.findViewById(R.id.vdop); //TODO Make it update periodically updateGPSInfo(); return builder.create(); }
From source file:com.app.sniffy.MainActivity.java
public void showTerms() { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View dialoglayout = inflater.inflate(R.layout.terms, null); WebView webView = (WebView) dialoglayout.findViewById(R.id.termsView); webView.loadUrl("file:///android_asset/license.html"); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Terms & Conditions"); builder.setView(dialoglayout).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { CheckBox checkBox = (CheckBox) dialoglayout.findViewById(R.id.checkBox); if (checkBox.isChecked()) { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("userconsent", true); editor.commit(); try { new GetKey(context).execute( new URI(Utils.getConfigProperty(getResources(), "generate-key") + mDeviceId + Utils.getConfigProperty(getResources(), "securekey"))); } catch (URISyntaxException e1) { Log.d("main activity key generate", e1.toString()); }/*ww w . jav a2 s . co m*/ } else { showTerms(); } } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:app.screen.PopupInfoDialogFragment.java
/** pull in the fragment layout {@link R.id#ttf_dialog_info} and create the dialog */ @Override/*from w ww. j ava2s . com*/ public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View rootView = getActivity().getLayoutInflater().inflate(R.layout.dialog_fragment, null); // set the info text field value TextView ttf_info = (TextView) rootView.findViewById(R.id.ttf_dialog_info); ttf_info.setText(item); builder.setView(rootView).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { getDialog().cancel(); } }); builder.setCancelable(false); return builder.create(); }