Menu
  • HOME
  • TAGS

Material dialog library- onPositive Button clicked dismiss

android,android-dialog,material-design

add: autoDismiss(false) new MaterialDialog.Builder(mainActivity) .title(R.string.title) .autoDismiss(false) .content(R.string.content) .positiveText(R.string.positive) .negativeText(R.string.negative) .positiveColor(setColor()) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { } }) .negativeColor(setColor()) .typeface(titleAndActions, contentAndListItems) .build() .show(); ...

Showing dialog as fullscreen

android,android-dialog

Dialog's do not support action bars....bummer. BUT, dialog's do support toolbars. I was able to user a toolbar to get a consistent look and feel across the full screen activity and the activity shown as a dialog....

Use ProgressDialog in a non activity class

android,android-activity,android-dialog,android-progressbar

Initialize the ProgressDialog in onPreExecute @Override protected void onPreExecute() { super.onPreExecute(); prg = new ProgressDialog(context); prg.show(); prg.setMessage("Loading..."); prg.setCancelable(false); } ...

Viewpager in Gallery dialog android

android,android-viewpager,android-dialog

Can you check this link please http://androidsharper.blogspot.com/2014/08/dialog-with-view-pager.html and http://tiku.io/questions/3558818/viewpager-in-simple-dialog

View in Dialog too small, cutting off text

android,android-dialog

The problem is from the added custom view that you implemented in your alertDialog setView(new View(mContext)) What will happen is that it will have a space where the view will be placed resulting to the inline message to be cut off since it is long. just remove it or create...

How to align an activity with dialog theme in horizontally center in android

android,android-layout,android-dialog

Simple that, Gravity set centre only like that: wmlp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL; replace with wmlp.gravity = Gravity.CENTER; Also change that: wmlp.width = LayoutParams.MATCH_PARENT; to wmlp.width = LayoutParams.WRAP_CONTENT; xml file <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="10dp" android:background="@drawable/layout_bg"...

Pop up dialog is shown twice in android

android,alertdialog,android-dialog

Actually you are triggering twice the code block to show the Alert Dialogue. So Alert Dialogue is showing one above another. It is not related with OK button click. There is no issues with the code snippet provided....

Create dialog like DatePicker

android,android-dialogfragment,android-dialog,android-datepicker

Sorry, but I can't comment because I don't have enough rep. There isn't a ready out of the box dialog that allows custom data to be set. I supposed the best approach would be to create a custom layout with a NumberPicker and then set it as your dialog's view....

How to change the text of a Dialog in Android?

java,android,google-play-services,android-gcm,android-dialog

You can override desired string value in your application's strings.xml like this. Simply add these lines in your strings.xml For message on dialog <string name="common_google_play_services_update_text" msgid="448354684997260580">This app won\'t run unless you update Google Play services.</string> For title on dialog <string name="common_google_play_services_update_title" msgid="6006316683626838685">out of date</string> EDIT You could find more information...

Making a custom dialog undismissable in android

android,android-dialog,customdialog

You can use dialog.setCancelable(false); dialog.setCanceledOnTouchOutside(false); reference...

Custom NumberPickerPreference - how to set the NumberPicker value?

android,sharedpreferences,android-preferences,android-dialog,numberpicker

Okay I had to apply 2 fixes to my custom preference: mPicker.setValue() should be called after setMinValue() and setMaxValue() have been called. mPicker.clearFocus() should be called before reading its value - as workaround for situations when user edits the value in the TextEdit and then clicks OK button in the...

unable to add window token null is not for an application when using accessibility in android

android,android-activity,android-context,android-dialog

You can use getApplicationContext(), but after that line, you should add this flag of WindowManager: dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); and the error will not show...

Can I close an application when a negative button on a dialog is clicked?

android,android-dialog

Your problem is that you cant access your activity from this class that you have created. The best way to deal with this problem is to use Listener interface. It allows you to capture the event when user clicks 'No' in dialog in you Activity class. Create a interface in...

How to get user selected string value in Android Popup dialog?

android,dialog,android-dialog

The which returned in onClick() is the index of the selected item. In your case, getting the string value associated that would be items[which] (you may need to make items final to ensure access within onClick())...

Android custom Listview dialog

android,listview,android-listview,android-dialog

mainListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { // Do things that use the position or // the view content to understand user input } }); ...

Can't show Spinner DropDown list inside a dialog

java,android,android-spinner,android-dialog

You find the spinner directly. Chanage spinner = (Spinner)findViewById(R.id.languagespinner); to spinner = (Spinner)settingdialog.findViewById(R.id.languagespinner); ...

Why doesn't DialogFragment.dismiss kill the dialog right away?

java,android,dialog,android-dialog,android-dialogfragment

If anyone's having a similar issue, the issue with my application was my OnTouchListener. When I set up on OnTouchListener to trigger the DialogFragment, here was my original code for doing so goTo - TextView private void setUpGoToTouchListener() { goTo.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) {...

Application crashing because of a NullPointerException in a custon ListView

android,android-listview,nullpointerexception,sharedpreferences,android-dialog

According to your debugging savedEntries == null. That is the reason for the NullPointerException here: savedEntries[position] Since you said that those array-values will be provided by the users later you can for example just add a null check to avoid this problem, something like this: if (savedEntries != null) {...

Android - How to check for button click in a custom alert dialog box?

java,android,user-interface,android-dialog,flat

You can call it by your dialog d i.e : Dialog d = new Dialog(MainActivity.this); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setContentView(R.layout.dialog); Button button = (Button) d.findViewById(R.id.share_button); Button button2 = (Button) d.findViewById(R.id.continue_button) d.show(); And then you can make a normal onClickListener button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //STUFF } }); Hope it helps...

How to start different activity for each positive button on the dialog shown from ListView item click event

android,listview,android-listview,android-dialog

You already have most of the code, you just need to add a check for the position that was clicked on that initiated the AlertDialog. You'll have to add a final int pos so that it can be accessed in the inner onClickListener() in setPositiveButton(): list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public...

Memory used by ImageView is never released

android,android-dialog

Although its still weird solved in following way: loading image by setting drawable and not resource directly: ((ImageView)dialog.findViewById(R.id.background_img)).setImageDrawable(getResources().getDrawable(R.drawable.preloader_bg_small)); and releasing it from memory by setting drawable to null ImageView background_image = ((ImageView) dialog.findViewById(R.id.background_img)); background_image.setImageDrawable(null); ...

Prevent Dialog (or DialogFragment) from closing when app goes to background

android,android-dialogfragment,android-dialog

First lets clear something, like you can see in the next images, your activity or fragment can be destroyed for many reasons, so you have to deal with what you want saving "the state of your dialog". Now the code: public class CustomProgressDialog extends Dialog { private static final String...

How to show DialogFragment android.support.v4.app.DialogFragment in android

android,android-dialog

Make a layout file and put your image in it (e.g. dialog_fragment.xml). Make your dialog fragment (e.g. MyDialogFragment.java) import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.Window; import android.widget.Button; public class MyDialogFragment extends DialogFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle...

How to use Autocompletetext view in Dialog window in Android

android,android-dialog,android-2.2-froyo

I don't see .show(); So to fix I think that you must do CityListDialog obj=new CityListDialog(context, COUNTRIES); obj.show(); ...

Android - Determinate ProgressDialog inside DialogFragment

android,android-dialogfragment,android-dialog

It isn't totally clear what the variable dialog inside setProgress(int progress) method is. But if you mean getDialog() by that, it takes time to create dialog by dialog fragment, and between the dialogFragment.show(getSupportFragmentManager(), "") and onCreateDialog(Bundle savedInstanceState) callback there will be some time interval, during which getDialog() will return null....

AlertDialog broken layout on some devices

android,android-layout,android-dialog,galaxy

It turned out that is was a problem with android:fitsSystemWindows and Android Lollipop like in this answer.

Format text in AlertDialog.Builder

android,android-dialog

You can't simply store HTML in a strings.xml file. You need to put them in CDATA, like so: <string name="id"><![CDATA[<i>Id: </i>]]></string> Then to display a formatted string, you still need to use Html.fromHtml()....

Alert dialog with button throws exception

android,android-dialog

Use it accordingly AlertDialog.Builder alertbox = new AlertDialog.Builder(YourActivity.this); alertbox.setTitle("Do you want To exit ?"); alertbox.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { // finish used for destroyed activity exit(); } }); alertbox.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { // Nothing will be happened...

Android: Passing parameters to Alert Dialog

android,android-ui,android-dialog

If you declare the variable as final then you can set it in your code before calling AlertDialog.Builder() and then access it in the onClick(), like this: final int someParameter = someValue; AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( this); alertDialogBuilder .setTitle("Are you sure?") .setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface...

How to show a pop up in Android and still be able to click on fragment

android,android-dialog,android-popupwindow

Use the PopupWindow class. It does exactly what you want. That's what has been used in the screenshot you posted above. Here's an example: How to Implement Popup Window in Android....

Dialog addContentView at the end of the dialog

android,android-layout,android-dialog

Quoted from the Android docs Generally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other. So you should probably not give it a child because...

Adding an Action Bar to a custom Dialog

java,android,android-layout,android-listview,android-dialog

Wrap all with a relativelayout and insert another relativelayout as the actionbar with alignment top. You can align your main layout below the actionbar. If you want the shadow effect of material design, add elevation 8dp to the actionbar-like layout.

how to show same Dialog in Activity and Fragment in Different situation?

dialog,android-dialogfragment,android-dialog

I did some research and got the solution. You need to use callback method in fragment. For this purpose,you need to use the following codes: your_button_on_fragment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ((YourActivityName)getActivity()).showRegisterDialog(); } }); ...

Show dialog using getApplicationContext() - BadTokenException: Unable to add window

android,android-dialog

But I am still confused what happens if I use getApplicationContext() to display a Dialog. You blow up. But if I use SomeActivity.this context it works fine. Correct. A Dialog is owned by an Activity. You cannot use an Application, Service, or other Context to show a Dialog. Note,...

How can I dont show the preference dialog after user select the listpreference

android,sharedpreferences,android-dialog

ListPreference listPreference = new ListPreference(this); Dialog dialog = listPreference.getDialog(); if (dialog != null) { dialog.hide(); } ...

AsyncTask Dialog Not Dismissed

java,android,android-asynctask,android-dialog

I'm using the following method to ensure the Dialog is dismiss once the task has completed, private void hideProgress() { if (pDialog != null) { if (pDialog.isShowing()) { pDialog.dismiss(); pDialog = null; } } } It avoids getting a null and forcibly closes a dialog....

Get editText value from alertDialog builder

android,android-dialog

For find view from Diloag then you have to give refference of that view of Dialog. LayoutInflater inflater = MainActivity.this.getLayoutInflater(); View mView = inflater.inflate(R.layout.dialog_save, null); final EditText etSearch = (EditText)mView.findViewById(R.id.etSearchText); builder.setView(mView) Full Code : public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will...

Dialog is not closed dialog.dismiss() when navigating backand forth to settings screen

android,android-dialog

dialog is used inonstart() please use in oncreate(), when your back to your actvity it's called the onstart() and onresume(), please read the activity lifecyclelifecycle @Override protected void onStart() { super.onStart(); if(!start_dialog) { start_dialog = true; open(getResources().getString(R.string.location_not_enabled)); } } ...

DialogFragment buttons color change in Lollipop

android,android-5.0-lollipop,android-dialog,android-dialogfragment

If you can create the dialog using AlertDialog the following worked for me: public class DialogTest extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()).setTitle("Test") .setMessage("This is a dialog.") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub }...

Android set Text in Dialog 1 from Dialog 2?

android,android-dialog

Because, there is no reference of TextView dateText in Second dialog, as It always remain NULL (Its only available after initializing from First dialog) Just pass your dateText reference to showDialog() Like, public void showDateDialog(final TextView dateText) { Calendar newCalendar = Calendar.getInstance(); fromDatePickerDialog = new DatePickerDialog(MainActivity.context, new DatePickerDialog.OnDateSetListener() { public...

Customize the “Select input method” Dialog

android,root,android-dialog,android-input-method

At the end the best solution was simple and didn't even require rooting: Create a custom keyboard with a 'KeyboardView' object and set this keyboard in the required way.

Dialog fire non-static methods in main activity

java,android,android-dialog,android-dialogfragment

You need to call a method which is non-static using the object. You can't call it using just the class name. Change to this AddMovieDialog addMovieDialog = new AddMovieDialog(); addMovieDialog .setOnFinishListener(new OnFinishListener() { public void finish() { } }); Also shouldn't if (AddMovieDialog.this.onCloseListener != null) AddMovieDialog.this.onCloseListener.finish(); be if (AddMovieDialog.this.onFinishListener !=...

Softkeyboard not showing in AlertDialog for phone only

android,android-alertdialog,android-softkeyboard,android-dialog,android-input-method

I solved the problem AlertDialog alertDlg = builder.create(); alertDlg.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); alertDlg.show(); ...

how to move button left,right,top,buttom in android?

android,image,android-service,android-animation,android-dialog

every thing so easy if you use custom view for dialog.Here is good tutorial. You may try it. Good luck!

Getting a run time error in popup menu “InvocationTargetException”

android,android-manifest,android-dialog,android-menu,android-popupwindow

Your code is fine just put the button in a container layout like relative layout ,linear layout etc. in your HomeScreen.xml file ... <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"...

How to make custom dialog with rounded corners in android

android,android-dialog

Create a xml in drawable , say dialog_bg.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/white"/> <corners android:radius="30dp" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> </shape> set it as the background in your layout xml android:background="@drawable/dialog_bg" set the background of your dialog to transparent dialog.getWindow().setBackgroundDrawable(new...

Trying to make ImageView full size in Dialog doesn't work

java,android,android-fragments,android-imageview,android-dialog

Call this method from fragment onCreateView or according to your requirements... private void showImage() { final Dialog nagDialog = new Dialog(getActivity(),android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); nagDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); nagDialog.setCancelable(false); nagDialog.setContentView(R.layout.test); Button btnClose = (Button)nagDialog.findViewById(R.id.btnIvClose); ImageView ivPreview = (ImageView)nagDialog.findViewById(R.id.iv_preview_image); // Loading image from url in ImageView ... HERE...

Android dialog is compressed

android,android-layout,android-dialog

Change your dialog box code with below code and it would would work for sure final Dialog d = new Dialog(MainActivity.this); //tell the Dialog to use the dialog.xml as it's layout description d.setContentView(R.layout.dialog); d.setTitle("Set Goal"); //Added this lines WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(d.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT;...