android-dialogfragment

Should we be using setTargetFragment()? I thought Fragments should not be communicating with each other

陌路散爱 提交于 2019-12-06 21:12:36
问题 The android developer tutorials recommend me using the host activities of fragments to pass around data and whatnot, so why is there a set/get target fragment method? My application thus far contains a host activity, and a fragment, which has a button that launches a DialogFragment , in which there is a button that launches ANOTHER DialogFragment . Using setTargetFragment/getTargetFragment has made this whole ordeal somewhat confusing though, so I am thinking of reimplementing to let my main

StackOverflowError when trying to inflate a custom layout for an AlertDialog inside a DialogFragment

不打扰是莪最后的温柔 提交于 2019-12-06 19:27:21
问题 I'm trying to create an AlertDialog, by using the Builder and setting a custom view. When I try to inflate the view inside of onCreateDialog, I get a StackOverflowError.. Here is the code up to the point where it loops back to onCreateDialog: @Override public Dialog onCreateDialog(Bundle savedInstanceState){ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.enter_time); LinearLayout outerLayout = (LinearLayout) getLayoutInflater(savedInstanceState

How to add action bar to a DialogFragment?

早过忘川 提交于 2019-12-06 15:35:33
How to add action bar to a DialogFragment ? I found a way to style an activity to the way we require and then display it as a dialog as in the following link ActionBar in a DialogFragment I need to set an action bar on a proper DialogFragment . Is it possible? Lan As Up ActionBar action on DialogFragment indicates: 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. But there's always the cases that I really want to use DialogFragment(which

How to create custom progressDialog

会有一股神秘感。 提交于 2019-12-06 15:30:30
At any devices we have different position of progressBar inside of the progressDialog. So I need to customize it. When I try like this: public class CustomProgressDialog extends ProgressDialog { public CustomProgressDialog(Context context) { super(context); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.progress_fragment_dialog); } } <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android

In a DialogFragment, what should onCreate do?

大兔子大兔子 提交于 2019-12-06 14:38:12
问题 I am currently messing around with DialogFragment to learn to use it. I assumed that compared to onCreateView() , onCreate() can do this: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); testTextView.setText("SUCCESS!"); //ERROR HERE } But I am wrong. Not sure why its not working. The error goes away when I comment out testTextView.setText("Success!"); The error is a NullPointerException, and then it just flags line 39 which is where the offending line of

Nullpointerexcepiton on cursor while selecting photo from gallery on dialog fragment

↘锁芯ラ 提交于 2019-12-06 07:28:45
问题 I'm trying to select photo from gallery through DialogFragment . But I'm getting nullpointerexception while initializing cursor . Any ideas why getting this error? Below is my code : if (resultCode == Activity.RESULT_OK) { Uri selectedImage = imageReturnedIntent.getData(); String[] filePathColumn = {MediaStore.Images.Media.DATA}; // Nullpointerexcepiton on this line Cursor cursor = getActivity().getContentResolver().query(selectedImage, filePathColumn, null, null, null); cursor.moveToFirst();

Starting DialogFragment from a class extending RecyclerView.ViewHolder

╄→尐↘猪︶ㄣ 提交于 2019-12-06 06:00:43
问题 I tried as below at onClick() method of recyelerview.viewholder class. SampleDialogFragment used in the sample extends DialogFragment. @Override public void onClick(View v) { SampleDialogFragment df= new SampleDialogFragment(); df.show(v.getContext().getSupportFragmentManager(), "Dialog"); } I'm facing problem at v.getContext().getSupportFragmentManager() . I can't call getSupportFragmentManager(). I also tried as below . @Override public void onClick(View v) { SampleDialogFragment df= new

How to pass listener from Fragment to DialogFragment

拜拜、爱过 提交于 2019-12-06 04:07:01
I have I Fragment that show DialogFragment .. The DialogFragment creates and shows a TimePickerDialog dialog. I want the calling Fragment to implement the imePickerDialog.OnTimeSetListener listener. but I don't know how to pass this listener to the Called fragment (The DialogFragment) .. I have found the following code that passes a listener from ACTIVITY to the DialogFragment . @Override public void onAttach(Activity activity) { super.onAttach(activity); mActivity = activity; // This error will remind you to implement an OnTimeSetListener // in your Activity if you forget try { mListener =

remove white background in dialogfragment

半腔热情 提交于 2019-12-05 23:47:57
问题 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) {

Android Dialog fragment eliminate black borders (top & bottom)

独自空忆成欢 提交于 2019-12-05 20:56:36
Need to eliminate top and bottom borders from a dialog fragment. How do you do it? AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setCancelable(true); LayoutInflater inflater = LayoutInflater.from(activity); View view = inflater.inflate(R.layout.variants_dialog, null); // setup views setupListView(view); ... builder.setView(view); return builder.create(); // HERE I HAVE TOP & BOTTOM BLACK BORDERS This doesnt do nothing: builder.setView(view); AlertDialog result = builder.create(); result.getWindow().setBackgroundDrawable(new ColorDrawable()); return result; There is