I couldn't find a reasonable way to solve this. So I did the following
from the compound view

private FragmentManager getFragmentManager()
    {
      Context c = getContext();
      if (c instanceof Activity)
      {
         return ((Activity)c).getFragmentManager();
      }
      throw new RuntimeException("Activity context expected instead");
    }

Not that it doesn't work. Thought it is a reasonable compromise. Then i can do

public void onClick(View v)
   {
      Button b = (Button)v;
      if (b.getId() == R.id.fromButton)
      {
          DialogFragment newFragment = new
DatePickerFragment(this,R.id.fromButton);
           newFragment.show(getFragmentManager(),
"com.androidbook.tags.datePicker");
           return;
      }

      //Otherwise
       DialogFragment newFragment = new DatePickerFragment(this,R.id.toButton);
        newFragment.show(getFragmentManager(),
"com.androidbook.tags.datePicker");
        return;
   }//eof-onclick

Any ways if anyone is looking to see how to do compound controls that
manage their own state and also use fragment dialogs you may want to
look at my attempt at doing this

Principles of Compound Controls: A semi article
http://satyakomatineni.com/item/4341
(principles, sample code, images, and research)

Thanks
Satya

On Tue, Oct 30, 2012 at 3:40 PM, Satya Komatineni
<satya.komatin...@gmail.com> wrote:
> Examples of fragment dialogs look like this
>
> SomeActivity
> {
>     public void buttonClicked(View someView)
>     {
>         DialogFragment newFragment = new DatePickerFragment();
>         newFragment.show(getFragmentManager(), "timePicker");
>     }
>     public static class DatePickerFragment extends DialogFragment(){ .... };
> }
>
>
> If you have a compound control extending a layout like a linear layout
> how do you isolate this to the view? how do you get a
> "fragmentManager" from the bowels of a view? or do you pass that to
> the view explicitly?
>
> Thank you very much for your help
> Satya



-- 
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to