List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { boolean retval = true; switch (item.getItemId()) { case R.id.action_create_dir: { EditNameDialog dialog = EditNameDialog.newInstance(getString(R.string.uploader_info_dirname), "", -1, -1, this); dialog.show(getSupportFragmentManager(), "createdirdialog"); break;//from w w w .j av a 2 s.c o m } case R.id.action_sync_account: { startSynchronization(); break; } case R.id.action_upload: { showDialog(DIALOG_CHOOSE_UPLOAD_SOURCE); break; } case R.id.action_settings: { Intent settingsIntent = new Intent(this, Preferences.class); startActivity(settingsIntent); break; } case R.id.action_create_file: { final String currentDir = getCurrentDir().getRemotePath(); if (!currentDir.contains("Shared")) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Create new file "); alert.setMessage("Please enter the name of the file "); LayoutInflater factor = LayoutInflater.from(getApplicationContext()); final View deleteDialogView = factor.inflate(R.layout.enter_filename_dialog, null); alert.setView(deleteDialogView); final EditText edittext = (EditText) deleteDialogView.findViewById(R.id.filename); //Log.d(TAG, getCurrentDir().getRemotePath()); alert.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { value = edittext.getText().toString(); Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext()); // Log.d(TAG, "you entre "+str+" "+value); int flag = 0; String[] fspl = value.toString().split("\\."); String taskInput; if (fspl.length == 1) { value = value + ".txt"; } else if (!fspl[fspl.length - 1].equals("txt")) { value = value + ".txt"; } uri = "file:///sdcard/ownCloud/" + account.name + currentDir + value; final File f2 = new File(Environment.getExternalStorageDirectory(), "ownCloud/" + account.name + currentDir); final File f1 = new File(Environment.getExternalStorageDirectory(), "ownCloud/" + account.name + currentDir + value); try { if (!f2.exists()) { f2.mkdirs(); } if (f1.createNewFile()) { Intent intent = new Intent(Intent.ACTION_EDIT); intent.setDataAndType(Uri.parse(uri), "text/plain"); startActivity(intent); flag = 1; } } catch (IOException e) { e.printStackTrace(); } finally { if (flag == 1) { taskInput = f1.getAbsolutePath() + "#" + currentDir + value; new displayFileTask(taskInput).execute(); } } } }); alert.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert.show(); } else { Toast.makeText(getApplicationContext(), "You cannot create files here ", Toast.LENGTH_SHORT).show(); } break; } case R.id.action_friend: { Intent friendsIntent = new Intent(this, TabLayoutActivity.class); startActivity(friendsIntent); break; } case R.id.action_group: { Intent groupIntent = new Intent(this, GroupActivity.class); startActivity(groupIntent); } break; case android.R.id.home: { FileFragment second = getSecondFragment(); OCFile currentDir = getCurrentDir(); if ((currentDir != null && currentDir.getParentId() != 0) || (second != null && second.getFile() != null)) { onBackPressed(); } break; } default: retval = super.onOptionsItemSelected(item); } return retval; }
From source file:ws.crandell.newspaperpuzzles.wordsearch.view.WordSearchActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog;/*from w w w. j a v a 2 s . c o m*/ switch (id) { case DIALOG_ID_NO_WORDS: { final DialogNoWordsListener DIALOG_LISTENER_NO_WORDS = new DialogNoWordsListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.ws_no_words); builder.setNegativeButton(R.string.ws_category, DIALOG_LISTENER_NO_WORDS); builder.setPositiveButton(R.string.ws_new_game, DIALOG_LISTENER_NO_WORDS); builder.setNeutralButton(R.string.ws_size, DIALOG_LISTENER_NO_WORDS); dialog = builder.create(); break; } case DIALOG_ID_NO_WORDS_CUSTOM: { final DialogNoWordsCustomListener DIALOG_LISTENER_NO_WORDS_CUSTOM = new DialogNoWordsCustomListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.ws_no_words_custom); builder.setNegativeButton(R.string.ws_category, DIALOG_LISTENER_NO_WORDS_CUSTOM); builder.setPositiveButton(R.string.ws_custom_editor, DIALOG_LISTENER_NO_WORDS_CUSTOM); dialog = builder.create(); break; } case DIALOG_ID_GAME_OVER: { final DialogGameOverListener DIALOG_LISTENER_GAME_OVER = new DialogGameOverListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("blank"); EditText text = new EditText(this); text.setSingleLine(); text.setId(android.R.id.input); builder.setView(text); builder.setPositiveButton(R.string.ws_SAVE_SUBMIT, DIALOG_LISTENER_GAME_OVER); builder.setNeutralButton(R.string.ws_SAVE, DIALOG_LISTENER_GAME_OVER); builder.setOnCancelListener(DIALOG_LISTENER_GAME_OVER); dialog = builder.create(); break; } case DIALOG_ID_HIGH_SCORES_LOCAL_SHOW: { final DialogHighScoresLocalShowListener DIALOG_LISTENER_HIGH_SCORES_SHOW = new DialogHighScoresLocalShowListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("blank"); builder.setTitle(R.string.ws_LOCAL_HIGH_SCORES); builder.setNegativeButton(R.string.ws_reset, DIALOG_LISTENER_HIGH_SCORES_SHOW); builder.setNeutralButton(android.R.string.ok, DIALOG_LISTENER_HIGH_SCORES_SHOW); builder.setPositiveButton(R.string.ws_GLOBAL, DIALOG_LISTENER_HIGH_SCORES_SHOW); dialog = builder.create(); break; } case DIALOG_ID_GAME_NEW: { final DialogGameNewListener DIALOG_LISTENER_GAME_NEW = new DialogGameNewListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(this.getString(R.string.ws_game_over)); builder.setPositiveButton(R.string.ws_new_game, DIALOG_LISTENER_GAME_NEW); builder.setNeutralButton(R.string.ws_REPLAY, DIALOG_LISTENER_GAME_NEW); builder.setNegativeButton(android.R.string.cancel, DIALOG_LISTENER_GAME_NEW); dialog = builder.create(); break; } case DIALOG_ID_INTRO_INPUT_TYPE: { final DialogIntroListener DIALOG_LISTENER_INTRO = new DialogIntroListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.ws_INTRO); builder.setPositiveButton(R.string.ws_tap, DIALOG_LISTENER_INTRO); builder.setNeutralButton(android.R.string.cancel, DIALOG_LISTENER_INTRO); builder.setNegativeButton(R.string.ws_drag, DIALOG_LISTENER_INTRO); dialog = builder.create(); break; } case DIALOG_ID_INTRO_DONATE: { final DialogInterface.OnClickListener LISTENER = new DialogIntroDonateListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.ws_INTRO_DONATE_MSG); builder.setPositiveButton(R.string.ws_DONATE, LISTENER); builder.setNegativeButton(R.string.ws_DONATE_NO, LISTENER); dialog = builder.create(); break; } case DIALOG_ID_DONATE: { final DialogInterface.OnClickListener LISTENER = new DialogDonateListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.ws_DONATE_MSG); builder.setPositiveButton(R.string.ws_DONATE_MARKET, LISTENER); builder.setNeutralButton(R.string.ws_DONATE_WEB, LISTENER); builder.setNegativeButton(R.string.ws_DONATE_NO, LISTENER); dialog = builder.create(); break; } default: dialog = super.onCreateDialog(id); break; } return dialog; }
From source file:net.sourceforge.kalimbaradio.androidapp.activity.DownloadActivity.java
@Override protected Dialog onCreateDialog(int id) { if (id == DIALOG_SAVE_PLAYLIST) { AlertDialog.Builder builder; LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); final View layout = inflater.inflate(R.layout.save_playlist, (ViewGroup) findViewById(R.id.save_playlist_root)); playlistNameView = (EditText) layout.findViewById(R.id.save_playlist_name); builder = new AlertDialog.Builder(this); builder.setTitle(R.string.download_playlist_title); builder.setMessage(R.string.download_playlist_name); builder.setPositiveButton(R.string.common_save, new DialogInterface.OnClickListener() { @Override/* w w w. j a v a 2s . c o m*/ public void onClick(DialogInterface dialog, int id) { savePlaylistInBackground(String.valueOf(playlistNameView.getText())); } }); builder.setNegativeButton(R.string.common_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.setView(layout); builder.setCancelable(true); return builder.create(); } else { return super.onCreateDialog(id); } }
From source file:com.abc.driver.MainActivity.java
public void chooseTruckLength(View v) { mTLtv = (TextView) findViewById(R.id.truck_length_tv); AlertDialog.Builder builder = new AlertDialog.Builder(this); GridView gridView1 = new GridView(this); gridView1.setNumColumns(3);/*from w w w. ja va 2 s . c o m*/ // (GridView)findViewById(R.id.gridView1); SimpleAdapter adapter = new SimpleAdapter(this, mTruckLengthList, R.layout.truck_length_griditem, new String[] { "TITLE", "TLENGTH" }, new int[] { R.id.griditem_title, R.id.griditem_length, }); gridView1.setAdapter(adapter); builder.setTitle("Please Choose"); builder.setInverseBackgroundForced(true); builder.setView(gridView1); final Dialog dialog = builder.create(); gridView1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { mTLtv.setText(((TextView) view.findViewById(R.id.griditem_title)).getText()); mTruckLength = ((TextView) view.findViewById(R.id.griditem_length)).getText().toString(); dialog.dismiss(); } }); // */ dialog.show(); }
From source file:com.abc.driver.MainActivity.java
public void chooseTruckType(View v) { mTTtv = (TextView) this.findViewById(R.id.truck_type_tv); AlertDialog.Builder builder = new AlertDialog.Builder(this); GridView gridView1 = new GridView(this); gridView1.setNumColumns(3);//from w ww. j a v a 2 s . co m // (GridView)findViewById(R.id.gridView1); SimpleAdapter adapter = new SimpleAdapter(this, mTruckTypeList, R.layout.truck_type_griditem, new String[] { "PIC", "TITLE", "TTYPE" }, new int[] { R.id.griditem_pic, R.id.griditem_title, R.id.griditem_type, }); gridView1.setAdapter(adapter); builder.setTitle("Please Choose"); builder.setInverseBackgroundForced(true); builder.setView(gridView1); final Dialog dialog = builder.create(); gridView1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { mTTtv.setText(((TextView) view.findViewById(R.id.griditem_title)).getText()); mTruckType = ((TextView) view.findViewById(R.id.griditem_type)).getText().toString(); dialog.dismiss(); } }); dialog.show(); }
From source file:com.abc.driver.MainActivity.java
public void chooseCargoType(View v) { mCTtv = (TextView) this.findViewById(R.id.cargo_type_tv); AlertDialog.Builder builder = new AlertDialog.Builder(this); GridView gridView1 = new GridView(this); gridView1.setNumColumns(3);/* w ww. j ava 2s .c om*/ // (GridView)findViewById(R.id.gridView1); SimpleAdapter adapter = new SimpleAdapter(this, mCargoTypeList, R.layout.cargo_type_griditem, new String[] { "PIC", "TITLE", "CTYPE" }, new int[] { R.id.griditem_pic, R.id.griditem_title, R.id.griditem_type, }); gridView1.setAdapter(adapter); builder.setTitle("Please Choose"); builder.setInverseBackgroundForced(true); builder.setView(gridView1); final Dialog dialog = builder.create(); gridView1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { // doing something in here and then close mCTtv.setText(((TextView) view.findViewById(R.id.griditem_title)).getText()); mCargoType = ((TextView) view.findViewById(R.id.griditem_type)).getText().toString(); dialog.dismiss(); } }); dialog.show(); }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Opens a url in an alert dialog./*from w ww . j a v a 2s .com*/ * * @param context * @param title * @param url */ public static void dialog_showUrlInDialog(Context context, String title, String url) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(title); WebView wv = new WebView(context); wv.loadUrl(url); wv.setHorizontalScrollBarEnabled(false); alert.setView(wv); alert.setNegativeButton("Close", null); alert.show(); }
From source file:com.mdlive.sav.MDLiveProviderDetails.java
/** * Parses JSON response from Cigna Coach request and displays popup displaying the extracted info * * data structure://from www . j a va 2s. co m * "appointment_instructions" : { * "title" : "Schedule an Appointment", * "description" : "To schedule a video coaching appointment, please call:", * "team_name" : "Marriott TakeCare Team", * "toll_free_number" : "1-800-700-1092", * "additional_info" : "Se habla Espaol" * } * * @param response HTTP response object */ private void handleCignaCoachSuccessResponse(String response) { //Fetch Data From the Services //Log.e("Response details", "************\n**********"+response.toString()); JsonParser parser = new JsonParser(); JsonObject responseObj = null, profileObj = null, providerObj = null, appointment_obj = null; String dialog_title = null, dialog_desc = null, dialog_teamname = null, dialog_extrainfo = null, phonenumber = null; try { responseObj = (JsonObject) parser.parse(response.toString()); profileObj = responseObj.get("doctor_profile").getAsJsonObject(); providerObj = profileObj.get("provider_details").getAsJsonObject(); appointment_obj = providerObj.get("appointment_instructions").getAsJsonObject(); dialog_title = appointment_obj.get("title").getAsString(); dialog_desc = appointment_obj.get("description").getAsString(); dialog_teamname = appointment_obj.get("team_name").getAsString(); phonenumber = appointment_obj.get("toll_free_number").getAsString(); dialog_extrainfo = appointment_obj.get("additional_info").getAsString(); } catch (NullPointerException nex) { //Log.e("Error details", "************\n" + nex.getMessage()); /*Toast.makeText(this, R.string.mdl_cignacoach_data_error, Toast.LENGTH_SHORT).show();*/ Snackbar.make(findViewById(android.R.id.content), getString(R.string.mdl_cignacoach_data_error), Snackbar.LENGTH_SHORT).show(); return; } final String dialog_phonenumber = phonenumber; AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MDLiveProviderDetails.this); LayoutInflater inflater = MDLiveProviderDetails.this.getLayoutInflater(); View dialogView = inflater.inflate(R.layout.cignacoach_popup, null); messagesView = dialogView; alertDialogBuilder.setView(dialogView); // populate the dialog's text fields final TextView txt_title = (TextView) dialogView.findViewById(R.id.title); txt_title.setText(dialog_title); final TextView txt_desc = (TextView) dialogView.findViewById(R.id.desc); txt_desc.setText(dialog_desc); final TextView txt_team = (TextView) dialogView.findViewById(R.id.team); txt_team.setText(dialog_teamname); final TextView txt_phone = (TextView) dialogView.findViewById(R.id.phone); txt_phone.setText(getString(R.string.mdl_cignacoach_phonenumber, dialog_phonenumber)); final TextView txt_extra = (TextView) dialogView.findViewById(R.id.extra); txt_extra.setText(dialog_extrainfo); alertDialogBuilder.setCancelable(true); // create alert dialog final AlertDialog alertDialog = alertDialogBuilder.create(); // suppress default background to allow rounded corners to show through alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); txt_phone.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (ContextCompat.checkSelfPermission(MDLiveProviderDetails.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(MDLiveProviderDetails.this, new String[] { android.Manifest.permission.CALL_PHONE }, MDLiveProviderDetails.PERMISSION_ACCESS_PHONE); } else { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + dialog_phonenumber)); startActivity(callIntent); } alertDialog.dismiss(); } }); // display it alertDialog.show(); }
From source file:com.bluekai.sdk.BlueKaiViewDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); if (blueKaiView == null) { blueKaiView = new WebView(getActivity()); WebViewClient client = new WebViewClient() { @Override/*from w w w .j a va2s . c om*/ public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); Logger.debug("BlueKaiView", "Error loading BK URL in webview -- " + errorCode + " -- " + description); errorOccured = true; if (listener != null) { listener.onViewLoaded(false, isExistingData(), getParamsList()); } } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (!errorOccured && listener != null) { errorOccured = false; listener.onViewLoaded(true, isExistingData(), getParamsList()); } } }; blueKaiView.setWebViewClient(client); WebSettings webSettings = blueKaiView.getSettings(); webSettings.setJavaScriptEnabled(true); int height = 1, width = 1; // if (devMode) { height = width = 300; // } RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); params.setMargins(10, 10, 10, 10); blueKaiView.setLayoutParams(params); blueKaiView.setBackgroundColor(Color.LTGRAY); alertDialogBuilder.setNegativeButton("Close", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); } blueKaiView.loadUrl(url); alertDialogBuilder.setView(blueKaiView); return alertDialogBuilder.create(); }