List of usage examples for android.app AlertDialog.Builder setIcon
public void setIcon(Drawable icon)
From source file:com.mk4droid.IMC_Activities.Fragment_NewIssueA.java
/** * OnCreateView /*from w ww . ja v a2s.c o m*/ */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { flagStarter = true; FActivity_TabHost.IndexGroup = 2; vfrag_nIssueA = inflater.inflate(R.layout.fragment_newissue_a, container, false); mfrag_nIssueA = this; ctx = this.getActivity(); //-------- tvUnauth ---- llUnauth = (LinearLayout) vfrag_nIssueA.findViewById(R.id.llUnauth); Button gotoSetup = (Button) llUnauth.findViewById(R.id.bt_nia_gosetup); gotoSetup.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getActivity().finish(); // Check if Activity Splash Already open if (Activity_Splash_Login.et_username == null) { Log.e("NIA", "SPLASH WAS NULL"); startActivity(new Intent(ctx, Activity_Splash_Login.class)); } getActivity().finish(); } }); //---- Spinner ----- ArrayList<Category> mCatL_Sorted = SortCategList(Service_Data.mCategL); SpinnerArrString = initSpinner(mCatL_Sorted); sp = (Spinner) vfrag_nIssueA.findViewById(R.id.spinnerCateg); adapterSP = new SpinnerAdapter_NewIssueCateg(getActivity(), //--- Set spinner adapter -- android.R.layout.simple_spinner_item, mCatL_Sorted); sp.setAdapter(adapterSP); sp.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) { if (flagStarter) { flagStarter = false; } else { spPosition = arg2; } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); //--------- Title ----- et_title = (EditText) vfrag_nIssueA.findViewById(R.id.etTitle_ni); if (et_title != null) if (et_title.getText().toString().length() > 0) titleData_STR = et_title.getText().toString(); if (titleData_STR.length() > 0) et_title.setText(titleData_STR); //------ Description ---- et_descr = (EditText) vfrag_nIssueA.findViewById(R.id.etDescription); if (et_descr != null) if (et_descr.getText().toString().length() > 0) descriptionData_STR = et_descr.getText().toString(); //------- Bt Attach image --- btAttachImage = (ImageButton) vfrag_nIssueA.findViewById(R.id.btAttach_image); //-------- Bt Proceed ----- btProceed = (Button) vfrag_nIssueA.findViewById(R.id.btProceed_ni_B); mshPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); resources = SetResources(); //--------- Layout ------- llnewissue_a = (LinearLayout) vfrag_nIssueA.findViewById(R.id.llnewissue_a); llnewissue_a.setVisibility(View.VISIBLE); //-------- Take Image button ------- if (flagPictureTaken && Image_BMP != null) { btAttachImage.setScaleType(ScaleType.CENTER_CROP); try { btAttachImage.setImageBitmap(Image_BMP); } catch (Exception e) { // if the btAttachImage was null set Image with some delay btAttachImage.postDelayed(new Runnable() { @Override public void run() { btAttachImage.setImageBitmap(Image_BMP); } }, 1000); } ; } else { btAttachImage.setScaleType(ScaleType.CENTER_INSIDE); btAttachImage.setImageResource(R.drawable.bt_custom_camera_round); //R.drawable.pattern_camera_repeater)); } btAttachImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(FActivity_TabHost.resources.getString(R.string.Attachanimage)); builder.setIcon(android.R.drawable.ic_menu_gallery); // 1 select builder.setPositiveButton(FActivity_TabHost.resources.getString(R.string.Gallery), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); Intent intent = new Intent(); intent.setType("image/jpeg"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE); } }); // 2 Shoot builder.setNeutralButton(FActivity_TabHost.resources.getString(R.string.Camera), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); // 2 shoot fimg = new File(image_path_source_temp); Uri uri = Uri.fromFile(fimg); Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST); } }); // 3 clear builder.setNegativeButton(FActivity_TabHost.resources.getString(R.string.Clear), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //dialog.cancel(); flagPictureTaken = false; File imagef = new File(image_path_source_temp); imagef.delete(); dialog.dismiss(); //btAttachImage.setCompoundDrawablesWithIntrinsicBounds( 0, R.drawable.bt_custom_camera_round, 0, 0); btAttachImage.setScaleType(ScaleType.CENTER_INSIDE); btAttachImage.setImageResource(R.drawable.bt_custom_camera_round); // btAttachImage.setPadding(0, 40, 0, 0); } }); builder.create(); builder.show(); } }); //------------- button Proceed ---------- btProceed.setOnClickListener(new OnClickListener() { @Override public void onClick(View vBt) { // Check if title is long enough and sent if (et_title.getText().toString().length() > 2 && spPosition != -1 && et_descr.getText().toString().length() > 2) { // RRR titleData_STR = et_title.getText().toString(); if (et_descr.getText().toString().length() > 0) descriptionData_STR = et_descr.getText().toString(); // Close Keyboard InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Service.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(et_title.getWindowToken(), 0); imm.hideSoftInputFromWindow(et_descr.getWindowToken(), 0); // Instantiate a new fragment. mfrag_nIssueB = new Fragment_NewIssueB(); Bundle args = new Bundle(); args.putInt("IndexSpinner", sp.getSelectedItemPosition()); mfrag_nIssueB.setArguments(args); // Add the fragment to the activity, pushing this transaction // on to the back stack. FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); ft.add(mfrag_nIssueA.getId(), mfrag_nIssueB, "FTAG_NEW_ISSUE_B"); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack(null); ft.commit(); } else if (spPosition == -1) { Toast.makeText(getActivity(), resources.getString(R.string.SelectaCategory), tlv).show(); } else if (et_title.getText().toString().length() <= 2) { Toast.makeText(getActivity(), resources.getString(R.string.LongerTitle), tlv).show(); } else if (et_descr.getText().toString().length() <= 2) { Toast.makeText(getActivity(), resources.getString(R.string.LongerDescription), tlv).show(); } } }); return vfrag_nIssueA; }
From source file:com.juick.android.ThreadActivity.java
public void sendMessageSucceed() { resetForm();/*from w w w . ja v a 2 s. co m*/ if (attachmentUri == null) { Toast.makeText(this, R.string.Message_posted, Toast.LENGTH_LONG).show(); } else { NewMessageActivity.getPhotoCaptureFile().delete(); // if any AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setNeutralButton(R.string.OK, null); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setMessage(R.string.Message_posted); AlertDialog alertDialog = builder.create(); alertDialog.show(); } doCancel(); }
From source file:me.piebridge.prevent.ui.PreventActivity.java
private void showTestDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.app_name) + "(" + BuildConfig.VERSION_NAME + ")"); builder.setMessage(R.string.soak_version); builder.setIcon(R.drawable.ic_launcher); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override//from ww w . j a v a 2s . c o m public void onCancel(DialogInterface dialog) { finish(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", BuildConfig.APPLICATION_ID, null))); finish(); } }); builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { init(); } }); builder.create().show(); }
From source file:com.mh_jmcdexample.projectblaze_mh.MainHomeFragActivity.java
public void logoutAlertdialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(R.mipmap.ic_matlauncher); builder.setTitle(R.string.logout_title); builder.setMessage(R.string.logout_message) .setPositiveButton(R.string.logout_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { session.setLogin(false); db.deleteUsers();/*from w ww . j av a2s . c o m*/ // Launching Login activity Intent intent = new Intent(MainHomeFragActivity.this, LoginActivity.class); startActivity(intent); finish(); } }).setNegativeButton(R.string.logout_no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); builder.show(); }
From source file:com.cloudtask1.AccountsActivity.java
/** * Sets up the 'connect' screen content. *//*from w w w . j av a 2s . c om*/ private void setConnectScreenContent() { List<String> accounts = getGoogleAccounts(); if (accounts.size() == 0) { // Show a dialog and invoke the "Add Account" activity if requested AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(R.string.needs_account); builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT)); } }); builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); builder.setIcon(android.R.drawable.stat_sys_warning); builder.setTitle(R.string.attention); builder.show(); } else { final ListView listView = (ListView) findViewById(R.id.select_account); listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView.setItemChecked(mAccountSelectedPosition, true); final Button connectButton = (Button) findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Set "connecting" status SharedPreferences prefs = Util.getSharedPreferences(mContext); prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit(); // Get account name mAccountSelectedPosition = listView.getCheckedItemPosition(); TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition); // Register register((String) account.getText()); finish(); } }); } }
From source file:at.jclehner.rxdroid.DrugEditFragment.java
private void showDrugDeleteDialog() { final String message = getString(R.string._title_delete_item, mWrapper.get().getName()) + " " + getString(R.string._msg_delete_drug); final AlertDialog.Builder ab = new AlertDialog.Builder(getActivity()); ab.setIcon(android.R.drawable.ic_dialog_alert); ab.setMessage(message);/*from w w w .j a v a2 s . co m*/ ab.setNegativeButton(android.R.string.no, null); ab.setPositiveButton(android.R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Database.delete(mWrapper.get()); Toast.makeText(getActivity(), R.string._toast_deleted, Toast.LENGTH_SHORT).show(); getActivity().finish(); } }); ab.show(); }
From source file:com.shafiq.mytwittle.view.HomeActivity.java
public void showPromote() { final View layout = View.inflate(this, R.layout.promote, null); // final EditText promoStatus = ((EditText) // layout.findViewById(R.id.promoStatusEditText)); // promoStatus.setText(R.string.free_for_life_promo_status); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(0); builder.setPositiveButton("Agree!", new Dialog.OnClickListener() { @Override/*from www. jav a 2 s .c om*/ public void onClick(DialogInterface dialog, int which) { TwitterFetchUsers.FinishedCallback callback = TwitterManager.get() .getFetchUsersInstance().new FinishedCallback() { @Override public void finished(TwitterFetchResult result, TwitterUsers users) { if (result.isSuccessful()) { String statusText = getString(R.string.promote_status_text); TwitterStatusUpdate statusUpdate = new TwitterStatusUpdate(statusText); TwitterManager.get().setStatus(statusUpdate, TwitterManager.get().getFetchStatusInstance().new FinishedCallback() { @Override public void finished(TwitterFetchResult result, TwitterStatus status) { if (result.isSuccessful()) { showFreeForLifeSuccess(); } else { showFreeForLifeError(); } } }); } } }; getApp().triggerFollowPromoAccounts(callback); } }); builder.setNegativeButton("Cancel", null); builder.setView(layout); builder.setTitle("Promote MyTwittle!"); AlertDialog alertDialog = builder.create(); alertDialog.show(); }
From source file:nz.ac.wintec.soit.af5.AccountsActivity.java
/** * Sets up the 'connect' screen content. *//*w w w. j ava 2s .c o m*/ private void setConnectScreenContent() { List<String> accounts = getGoogleAccounts(); if (accounts.size() == 0) { // Show a dialog and invoke the "Add Account" activity if requested AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(R.string.needs_account); builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT)); } }); builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); builder.setIcon(android.R.drawable.stat_sys_warning); builder.setTitle(R.string.attention); builder.show(); } else { final ListView listView = (ListView) findViewById(R.id.select_account); listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView.setItemChecked(mAccountSelectedPosition, true); final Button connectButton = (Button) findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Set "connecting" status SharedPreferences prefs = Util.getSharedPreferences(mContext); prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit(); // Get account name mAccountSelectedPosition = listView.getCheckedItemPosition(); TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition); // Register register((String) account.getText()); finish(); } }); } }
From source file:org.digitalcampus.oppia.widgets.QuizWidget.java
private void showFeedback(String msg) { AlertDialog.Builder builder = new AlertDialog.Builder(super.getActivity()); builder.setTitle(super.getActivity().getString(R.string.feedback)); builder.setMessage(msg);/*from ww w . j a v a2 s .c o m*/ try { if (this.quiz.getCurrentQuestion().getScoreAsPercent() >= Quiz.QUIZ_QUESTION_PASS_THRESHOLD) { builder.setIcon(R.drawable.quiz_tick); } else { builder.setIcon(R.drawable.quiz_cross); } } catch (InvalidQuizException e) { e.printStackTrace(); } builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { if (QuizWidget.this.quiz.hasNext()) { QuizWidget.this.quiz.moveNext(); QuizWidget.this.showQuestion(); } else { QuizWidget.this.showResults(); } } }); builder.show(); try { this.quiz.getCurrentQuestion().setFeedbackDisplayed(true); } catch (InvalidQuizException e) { e.printStackTrace(); } }
From source file:monakhv.android.samlib.AuthorListFragment.java
/** * Create Alert Dialog to wrn about Author delete * * @param authorName Name of the author/*from ww w .j a v a 2s .co m*/ * @return Warning Author delete dialog */ private Dialog createDeleteAuthorAlert(String authorName) { AlertDialog.Builder adb = new AlertDialog.Builder(getActivity()); adb.setTitle(R.string.Attention); String msg = getString(R.string.alert_delete_author); msg = msg.replaceAll("__", authorName); adb.setMessage(msg); adb.setIcon(android.R.drawable.ic_dialog_alert); adb.setPositiveButton(R.string.Yes, deleteAuthorListener); adb.setNegativeButton(R.string.No, deleteAuthorListener); return adb.create(); }