Menu
  • HOME
  • TAGS

Error when alert dialog shown

android,dialogfragment

builder.setTitle(paramValues.get(0)); you are accessing paramValues before initializing it, which takes place 5 lines below. If I were in you I would avoid keeping static references that holds the data you want to show. You are using a subclass of DialogFragment and you should us the setArguments/getArguments pair to handle...

ListView in DialogFragment is disabled in Android 4.0

android,dialogfragment

As mentioned in the Android Developer Guide for Dialogs, you can use AlertDialog.Builder.setAdapter instead of AlertDialog.Builder.setItems to back the list with dynamic data (it specifically mentions data from a Loader). The following example uses a Handler to populate the list 5 seconds after start instead of a Loader for simplicity....

Non English text in Android DialogFragment shows as question marks

android,dialogfragment

Create folder values-he inside res folder and copy strings.xml file here from res ⇒ values ⇒ strings.xml location. Go to res ⇒ values ⇒ strings.xml then declare string: <string name="hebrew_title">hello</string> Go to res ⇒ values-he ⇒ strings.xml then declare string: <string name="hebrew_title">שלום</string> Then in your code write like this: .setTitle(getResources().getString(R.string.hebrew_title))...

DialogFragment attaches to MainActivity instead of parent fragment activity

java,android,android-activity,android-fragments,dialogfragment

your app crashes here mListener = (SensorRateChangeListener) activity; because it's expecting your Main Activity to be like this: public class MainAcivity extends Activity implements SensorRateChangeListener{ since you implemented the SensorRateChangeListener interface in another fragment, it crashed. so just implement the SensorRateChangeListener interface in MainActivity or just implement a method like...

What is a dialog context?

c#,android,xamarin,dialogfragment

this in this line means an instance of TrabalharFicheiro class. var test = new TrabalharFicheiro (this.Activity); should be used....

How to pass data between multiple Fragments in Android

android,android-tabhost,android-listfragment,android-dialogfragment,dialogfragment

There's no magic. You can achieve with two approaches. Use callback. Create interface and class to pass the data through child Fragment to Activity. You don't need to modify bridged TabHostFragment as Fragment always rely on its mother Context (Activity) no matter how many fragments wrap the fragment. public class...

Android get rid of DialogFragment floating margin

java,android,dialogfragment

The solution is to add this line: setStyle(DialogFragment.STYLE_NO_FRAME, 0); ...

Up ActionBar action on DialogFragment

android,android-dialogfragment,android-actionbar-compat,dialogfragment

There is no way to attach an ActionBar to the DialogFragment even though you can set the theme of the DialogFragment it will not register as a ActionBar to it, Dialog.getActionBar() will always return null. Instead of getting the ActionBar you can always attach a Layout that will look like...

Can't dismiss a custom DialogFragment Android

android,onclick,android-dialogfragment,dismiss,dialogfragment

Directly set your Button Click Listener in onCreateView(...) @Override public View onCreateView(....) { ....... ....... negativeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); ....... } ...

DialogFragment and addToBackstack method connection

android,fragment,dialogfragment

Alright, after writing more code using the DialogFragment solution including more tests I came to the reason (most likely the key reason) of why to use the addToBackStack way, right after removing the previous dialog. The reason for it (silly me that I missed that) is that it will make...

Calling findViewById() from DialogFragment subclass gives NullPointerException

android,view,nullpointerexception,findviewbyid,dialogfragment

When you are calling findViewById(), you are doing so from an inner class of your Activity, which is where this method comes from. Since that view id doesn't exist in your activity's layout, you get null. Your dialog fragment has to inflate its layout (as you have found) before it...

Android - Floating Alert Dialog which still enables user input in the main layout/activity

android,android-dialogfragment,dialogfragment

you can get window object and set it's layout parameters below code might help you. Window window = getDialog().getWindow(); // set "origin" to top left corner, so to speak window.setGravity(Gravity.TOP|Gravity.LEFT); // after that, setting values for x and y works "naturally" WindowManager.LayoutParams params = window.getAttributes(); params.x = 300; params.y =...

DialogFragment shows onBack button press even if I remove it

android,android-activity,back-stack,dialogfragment

Finally I have found the reason and the correct answer. the problem is with: ft.addToBackStack(null); From document: Add this transaction to the back stack. This means that the transaction will be remembered after it is committed, and will reverse its operation when later popped off the stack. Parameters name An...

How to get data from SimpleDialogFragment to a Fragment?

java,android,android-fragments,dialogfragment,simpledialog

Suppose you have this code where you're creating your dialog FragmentManager fm = getActivity() .getSupportFragmentManager(); PedirTaxiDialog dialog = PedirTaxiDialog(); dialog.setTargetFragment(MainFragment.this, "some request tag"); dialog.show(fm, "Salvar Favoritos"); By calling method setTargetFragment() you're enabling option to get result from your DialogFragment as you're getting result from activity when you're starting it using...

NullPointerException on DialogFragment at onResume()

android,nullpointerexception,onresume,dialogfragment

It's probably because onResume is called before onCreateDialog. Therefore getDialog returns null. What you want to do is to set the listener once the dialog is created, or even when it's created: @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(android.content.DialogInterface dialog,...

commitAllowingStateLoss on DialogFragment

android,android-fragments,android-dialogfragment,dialogfragment

I think to prevent throwing IllegalStateException on DialogFragment might be better to use : YourDialogFragment dialogFragment = new YourDialogFragment (); fragmentManager.beginTransaction().add(dialogFragment, YourDialogFragment .TAG_FRAGMENT).commitAllowingStateLoss(); except using show on DialogFragment....

EditText.getText() returns the default/initial value when called in an inner class

java,android,inner-classes,dialogfragment

Remove following line from your onClick method and use it in builder.setView(). Because of this line view is being reset to its original form and changes made to edit text is lost. v = inflater.inflate(R.layout.input_dialog, null); Like this AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); inflater = getActivity().getLayoutInflater(); builder.setTitle("Identity verification"); // Inflate...

NumberPicker not working inside DialogFragment

android,android-dialogfragment,numberpicker,dialogfragment

You have to provide the picker with array of what you are trying to select. String[] myStringArray = new String[]{"a","b","c"}; mMinutePicker.setMinValue(0); mMinutePicker.setMaxValue(myStringArray.length - 1); mMinutePicker.setDisplayedValues(myStringArray); And Change Dialog alertDialog = new AlertDialog.Builder(getActivity()) .setTitle(title) .setView(inflater.inflate(R.layout.activity_time_picker, null)) to Dialog alertDialog = new AlertDialog.Builder(getActivity()).setTitle(title).setView(view) You are inflating the view again....