0

I would like to set up a dialog box in my fragment class. I have done this before with normal activity class, but not with fragment.

I am following this answer HERE that someone has already answered, but I'm getting an error. Will that answer work within a fragment?

I am wanting to open the dialog on image click that I have set up already from an ImageView.

Any help would be great, thanks in advanace.

I would like the dialog code to go:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    final View v = inflater.inflate(R.layout.image_detail_fragment,
            container, false);

    mImageView = (RecyclingImageView) v.findViewById(R.id.imageView);
    mImageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {



          /HERE




        }

    });

    return v;
}
Community
  • 1
  • 1
Jack
  • 2,043
  • 7
  • 40
  • 69

1 Answers1

0

If you are using fragments then you should be using DialogFragments instead of the old Dialog box.

http://developer.android.com/reference/android/app/DialogFragment.html

Kuffs
  • 35,581
  • 10
  • 79
  • 92
  • If I used the Dialog fragment, would I still be able to use the "mImageView" I have set up in my class from the Dialog fragment class? – Jack Oct 08 '13 at 14:27
  • A DialogFragment is just another class. You can control and pass it arguments just like you would any other. – Kuffs Oct 08 '13 at 14:34
  • OK, I have set up the dialog fragment. How would I call it from my current class in on click? The class names "MyDialogFragment", Cheers. – Jack Oct 08 '13 at 14:47
  • You would be better to ask a new question rather than to continue to ask different questions in the comments of this one. Comments are not a good place for extended conversations. Try the docs first though. What you want is most likely there. – Kuffs Oct 08 '13 at 14:50
  • I would of thought it would of been a simple line of code, so there would be no need to write and ask a whole new question. Thanks anyway. – Jack Oct 08 '13 at 14:56
  • It possibly would be simple but as I do not know your code and you cannot enter it all into the comments, it makes more sense to explain your problem in a new question where you can fully explain your issue with proper code formatting etc. I already said you can manipulate the class like any other. I would have expected that this would be explanation enough as passing references between classes is a basic part of writing code. On top of that, I am leaving now so didn't want to leave you waiting for a response. – Kuffs Oct 08 '13 at 15:01