FAQ Database Discussion Community


Android Navigation Drawer & Dialog

android,android-fragments,navigation-drawer,android-alertdialog,android-dialogfragment
is it possible to display an AlertDialog/DialogFragment and keep the Navigation Drawer open? I have tried an Alert Dialog and a dialog fragment, but the drawer closes abruptly. AlertDialog: new AlertDialog.Builder(this) .setTitle("Title") .setMessage("Message") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // ... } }) .setIcon(android.R.drawable.ic_dialog_alert)...

windowSoftInputMode has no effect in Android M

android,android-activity,android-dialogfragment,android-m
I have a MainActivity with android:windowSoftInputMode="adjustNothing" set in the AndroidManifest. The Theme has parent Theme.AppCompat.Light.NoActionBar. I add a DialogFragment to this activity and show an AlertDialog inside of it, then set alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); inside the fragment. Now, on Android 5.1.1 it works as expected. The keyboard does not auto show when...

Implement DialogFragment interface in OnClickListener

java,android,android-listview,onclicklistener,android-dialogfragment
I need to build a DialogFragment which returns user input from the dialog to an activity. The dialog needs to be called in an OnClickListener which gets called when an element in a listview gets clicked. The return value of the DialogFragment (the input of the user) should be directly...

OnCreateView not called in a dialogfragment from a fragment

android,android-fragments,android-dialogfragment
I have a fragment that executes or display a dialog fragment once a button is clicked. This dialog fragment displays a table generated by code, however when I try to click the button on this is displayed And when I trace it in the LogCat the dialog fragments onCreateView is...

Android Custom Dialog Fragment callback not being called

android,callback,android-dialogfragment
So in my app i'm in need of using several confirmation dialogFragments of the same type, basically, it has a message, yes/no and a callback for the positive message. I managed to do it, except for the callback part, which i cant figure it out why it is not being...

Create dialog like DatePicker

android,android-dialogfragment,android-dialog,android-datepicker
I need to do a dialog like DatePicker or TimePicker, but the dialogue should display my data. Is this possible, or do I need to do a custom view for this?

Android - Set width of parent linear layout as percentage of the screen

android,android-layout,android-dialogfragment
Good day. Apologies for the confusing title. I am building an android application and I have a dialog fragment. The dialog fragment has a set width. However, the issue is that when the app is run on a device with a different screen size, the dialog fragment isn't centered properly....

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

dialog,android-dialogfragment,android-dialog
I am doing a sample Project where I am using Navigation Drawer with Fragments.When I click in row item1 it opens Dialog Fragment1 .In Dialog Fragment1 I have a button . My requirement is I want to open same Dialog which is triggred from navigation row item1 when button in...

DialogFragment with a custom title

android,android-layout,android-fragments,android-dialogfragment
I need to place a custom title to my DialogFragment. getDialog().setTitle("My Title"); is not enough for me because I want to change the title text and background colors. As you can see from the image below, with getDialog().setTitle("My Title"); I've no customization (as far as I know), ie, the text...

Android - Determinate ProgressDialog inside DialogFragment

android,android-dialogfragment,android-dialog
I know that Google's Material Design guidelines don't recommend using a ProgressDialog, instead using another less intrusive way to display progress, but I need to use a ProgressDialog for a specific Activity of my app. So, the thing is that I want to wrap a ProgressDialog inside a DialogFragment, and...

Dialog width not proper

android,android-dialogfragment
In my application i am using a dialog fragment to display a dialog.I code is working fine but the width is dialog is very small.My dialog looks like this I want the width of the dialog to be more but its not happening Code public class MyResourceDialog extends android.support.v4.app.DialogFragment {...

commitAllowingStateLoss on DialogFragment

android,android-fragments,android-dialogfragment,dialogfragment
I have an IllegalStateException on showing a DialogFragment : java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState i know why its happening but i want to using commitAllowingStateLoss on showing dialog by overriding DialogFragment show function : public void show(FragmentManager manager, String tag) { mDismissed = false; mShownByMe = true;...

How do I create a pop-up Android Fragment that takes in a text input before returning to my main activity?

android,android-fragments,android-fragmentactivity,android-dialogfragment
For my app, I want my user to be able to press a "Change User" button, have a fragment pop-up, take in a text input, and then save to shared preferences upon exit, returning to the activity it was called from. I would like my methodology to be similar to...

Cannot find DialogFragment with ChildFragmentManager

android,android-dialogfragment,android-fragmentmanager
In my app I have an AppCompatActivity which has a support fragment. From this fragment I am showing a DialogFragment as follows final MyDialogFragment completeDialogFragment = MyDialogFragment.newInstance(titleString, messageString, DialogType.Ok); completeDialogFragment.setDialogCallBack(new MyDialogFragment.DialogCallBacks() { @Override public void onPositive() { // some code to execute when Ok is pressed completeDialogFragment.dismiss(); } @Override public...

DialogFragment callback to Target Fragment using interface

android,android-fragments,interface,callback,android-dialogfragment
I am trying to send some data from a dialogfragment to the targeted fragment but its not working. I have written the following code, but it through exception: java.lang.NullPointerException: Attempt to invoke interface method 'void com.x.x.FragmentAlertDialog$Communicator.setI(java.lang.String)' on a null object reference Code: public class FragmentAlertDialog extends DialogFragment { Communicator callback;...

NullPointerException in DialogFragment

android,android-alertdialog,android-dialogfragment
I'm having some trouble with NullPointerException showing up when I click on the positive button of my DialogFragment. I set a layout mainly composed of EditText and I am using their contents in my app. The problems appears when the app tries to retrieve the contents of the EditText In...

Why am I getting TimePicker NullPointerException in android 4.0.3?

java,android,android-dialogfragment,android-timepicker
I have this class which is showing a time picker with a 10 minute interval: public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Calendar c = Calendar.getInstance(); int hour = c.get(Calendar.HOUR_OF_DAY); // Convert current minutes to tens // 55 = 50, 56 =...

How do I launch the soft keyboard after “Cancel” button is clicked in DialogFragment?

android,view,onclick,android-softkeyboard,android-dialogfragment
Fragment.java file: .... public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.skyfrag_layout, container, false); getDialog().setTitle("Delete skycard"); Button btnCancel = (Button) rootView.findViewById(R.id.btnCancel); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getDialog().cancel(); } }); ... I tried each of the below in the onClick function but neither...

Placing Tabs in DialogFragment

android,android-tabhost,android-dialogfragment
I am attempting to place TabHost inside of DialogFragment but at present it is none functional and returns null on the line: tabs.findViewById(R.id.tabHost); How can tabhost be initialized in the DialogFragment to allow the tabs to appear? Tabbed DialogLog class: public class InviteFriendTabbedAlertDialog extends DialogFragment { TabHost tabs; @Override public...

remove white background in dialogfragment

android,android-dialogfragment
Here's how I called my DialogFragment: DialogSelectAccount myDiag=new DialogSelectAccount(); myDiag.show(ft,"Diag" ); Here's how (partially) my DialogFragment is created: public class DialogSelectAccount extends DialogFragment { public DialogSelectAccount() { } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView =...

DialogFragment not recognizing finish() method

java,android,fragment,onclicklistener,android-dialogfragment
Hello ultimately what I am looking to do is to have a DialogFragment show on screen to confirm that the user wants to exit the app. If the user says that they do wish to close the app the app shuts down. If the user does not the DialogFragment goes...

Text selection tools in ActionBar are white on white background after selecting text in Dialog

android,dialog,android-actionbar,android-dialogfragment,textselection
Anyone had this issue, that after selecting text in dialog's EditText, toolbar appears with invisible action buttons (white on white background)? How do I set theme to a DialogFragment? ...

How to call an activity from a Dialogfragment in android?

android,android-intent,android-activity,nullpointerexception,android-dialogfragment
I want to call an activity from Dialogfragment, I have attached the code and logcat below for your reference on what I have tried.Kindly provide me your knowledge on it. Thank you. Intent intent = new Intent(getActivity(), LinkActivity.class); getActivity().startActivityForResult(intent, 0); Logcat: 02-12 13:47:17.345: E/AndroidRuntime(670): FATAL EXCEPTION: main 02-12 13:47:17.345: E/AndroidRuntime(670):...

saving instance state on memory low situations

android,android-fragments,android-listview,android-dialogfragment,low-memory
i have an alert dialog wrapped around by a DialogFragment class. the dialog has custom layout in which i show a list of items (i use a ListView with an appropriate adapter). the list of items is pretty huge and important, so i save it inside a Fragment class in...

Passing strings from an Activity to a DialogFragment

c#,android,xamarin,android-dialogfragment
in my activity I have this: public class MainActivity : Activity { RelativeLayout mRelativeLayout; Button mButton; private Button mBtnSignUp; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); mRelativeLayout = FindViewById<RelativeLayout>(Resource.Id.mainView); mButton = FindViewById<Button>(Resource.Id.btnLogin); mButton.Click += mButton_Click; mRelativeLayout.Click += mRelativeLayout_Click; mBtnSignUp =...

Dialog fire non-static methods in main activity

java,android,android-dialog,android-dialogfragment
I have a dialog that adds items to a listview, and when an item is added I need to reset the list adapter (because if not things get weird). I read here that I can create an event listener and listen to it in the main activity. I tried doing...

Passing data from DialogFragment to ArrayAdapter in ListFragment

android,android-listfragment,android-dialogfragment
I have ListFragment in which each row has button which after clicking opens dialogFragment in which user can choose 1 of 10 options (it is a listView of 10 options). I want to save this choice in SQLite database (it's already done) and reflect choice in the particular list row...

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

android,android-dialogfragment,android-dialog
It's pretty common for my app to show a progress or AlertDialog to the user. If the user puts the app into the background and then returns later, I want the Dialog to still be shown. Is there a way to make Android handle this? I'd like it to either...

How to change the layout of DialogFragment when the screen is rotated in Android

android,android-layout,android-fragments,android-dialogfragment,screen-rotation
I have a custom DialogFragment, which contains two DatePicker widgets (from and to, using layout/custom_date_picker). I need change the layout of dialogFragment when the screen is rotated to landscape (using layout-land/custom_date_picker). The configuration of the Activity is : <activity android:name=".activities.MainActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTop"/> The implemented DialogFragment source is: public class DatePickerDialog...

Dialog FLAG_DIM_BEHIND doesn't work on Android 5.x (Lollipop)

android,android-5.0-lollipop,android-dialogfragment
I dim the background of a DialogFragment using this code: Window window = getDialog().getWindow(); WindowManager.LayoutParams windowParams = window.getAttributes(); windowParams.dimAmount = 0.75f; windowParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND; window.setAttributes(windowParams); This works fine on Kitkat and below, but stopped working on Lollipop. I suspect it has to do with the fact that my Activity is...

How to pass data between multiple Fragments in Android

android,android-tabhost,android-listfragment,android-dialogfragment,dialogfragment
In my main Activity, I have a DialogFragment that contains a FragmentTabHost. I have two tabs, one that is a DialogFragment and one that is a ListFragment. When either the 'OK' button is pressed in the inner DialogFragment or when an element in the ListFragment is pressed, I want to...