android-dialogfragment

How to display, on MainActivity, the number inserted on a custom alertDialogFragment with EditText?

喜你入骨 提交于 2019-12-02 11:16:26
问题 I'm using a custom alertdialog with an editText to insert a number, the alertdialog is working, but nothing happens when I click positive button, it should display the value inserted, in main_activity.xml . It seems that my interface is not working. I don't know what I'm doing wrong, here is my code: TestAlertDialogFragment.java public class TestAlertDialogFragment extends DialogFragment { // Use this instance of the interface to deliver action events TestAlertDialogListener mListener; public

Error inflating Class fragment in DialogFragment

99封情书 提交于 2019-12-02 09:43:58
I am trying to create a dialogfragment with a listview inside of it and I used the accepted answer from this question to do it How to display an existing ListFragment in a DialogFragment But I am getting an Error inflating class fragment when I try to open the fragment dialog and the app crashes Below is the dialog_fragment_with_list_fragment layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <fragment android:id="@+id

How to display, on MainActivity, the number inserted on a custom alertDialogFragment with EditText?

↘锁芯ラ 提交于 2019-12-02 06:14:57
I'm using a custom alertdialog with an editText to insert a number, the alertdialog is working, but nothing happens when I click positive button, it should display the value inserted, in main_activity.xml . It seems that my interface is not working. I don't know what I'm doing wrong, here is my code: TestAlertDialogFragment.java public class TestAlertDialogFragment extends DialogFragment { // Use this instance of the interface to deliver action events TestAlertDialogListener mListener; public interface TestAlertDialogListener { public void onDialogPositiveClick(DialogFragment dialog, int i,

Correct way to remove a DialogFragment: dismiss() or transaction.remove()?

烂漫一生 提交于 2019-12-02 03:46:26
问题 I still have a problem due to a DialogFragment used on my main activity. I am currently using this code to remove it: FragmentTransaction transaction = getFragmentManager().beginTransaction(); Fragment frag = getFragmentManager().findFragmentByTag("LockDialog"); if(frag != null) { transaction.remove(frag); transaction.commit(); } The problem is that I am still getting crashes due to the fact that the dialog has duplicates (meaning the dialog was not properly removed sometimes). So my question

Implement DialogFragment interface in OnClickListener

那年仲夏 提交于 2019-12-02 03:20:02
问题 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 available in the OnClickListener in the activity. I tried to implement this by sticking to the official docs: http://developer.android.com/guide/topics/ui/dialogs.html#PassingEvents I need something like the

Implement DialogFragment interface in OnClickListener

五迷三道 提交于 2019-12-02 00:44:14
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 available in the OnClickListener in the activity. I tried to implement this by sticking to the official docs: http://developer.android.com/guide/topics/ui/dialogs.html#PassingEvents I need something like the following which doesn't work since I don't know how to make the anonymous OnClickListener implement the

NullPointerException calling activity using DialogFragment

百般思念 提交于 2019-12-01 14:15:48
I am in the process of converting my dialogs to DialogFragments . I'm following the instructions here but it looks like they are using it in an Activity and I'm using it in a Fragment . I've created the Listener back to my fragment, but when I call getActivity() it is throwing a NullPointerException : public class DialogTextAdd extends DialogFragment implements OnEditorActionListener { private EditText mText; public interface DialogTextAddListener { void onDialogTextAdd(final String inputText); } public DialogTextAdd() { // Empty constructor required for DialogFragment } @Override public View

Using image from street view

坚强是说给别人听的谎言 提交于 2019-12-01 14:09:33
I want to get a picture of streetview (stating latitude and longitude) and display in a dialog, is this possible? I saw some examples here, but not found one that show me how to display the image in dialog. Sorry if already exists this question in the site, but I not found when I search. Yes you can, as a URL root you can use this one http://cbk0.google.com/ or maps.google.com and this is a example where you use above mentioned URL by providing location: http://cbk0.google.com/cbk?output=xml&hl=x-local&ll=34.058593,-118.240673&it=all The result should be: <panorama> <data_properties image

How to set a default value to SharedPreferences programmatically?

情到浓时终转凉″ 提交于 2019-12-01 10:41:32
I am using SharedPreferences to keep the information about user's weight, which I need in my application. The problem is, how to set a default value (eg. 75 kg) automatically after installation? I know how to do it via .xml, but how to do this programmatically? My code: public class SettingsDialogFragment extends DialogFragment{ public static final String PREFS_NAME = "settings"; public Dialog onCreateDialog(Bundle savedInstanceState) { builder.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Data.weight = weight;

Soft Keyboard Doesnt show when using adapter in DialogFragment

末鹿安然 提交于 2019-12-01 08:32:19
I have a custom DialogFragment which has an ArrayAdapter in it which has some editTexts in it. When the dialog is shown the soft keyboard does not appear even if i press on the edit text. The edit text does take focus but the keyboard never comes up. If i do not use an adapter and just use a view with an edit text it works perfectly but as soon as i add the adapter i get the issue. My code is below. Any help would be really appreciated. Thanks in Advance. public class ParameterDialog extends DialogFragment { Context context; @Override public Dialog onCreateDialog(Bundle savedInstanceState) {