Re: [android-developers] Problem refreshing a fragment edittext view from a dialogFragment after rotation

2012-06-10 Thread João Rossa
Hi! Sorry for the late reply, so i created call backs, the DialogFragment
receives an interface type that the fragment that calls the dialog must
implement, this works well if setRetainInstance is set to true, but what if
i dont want to use this property?

regards,

On Thu, Jun 7, 2012 at 9:06 AM, al  wrote:

> setTargetFragment / getTargetFragment as per my last reply.
>
> Am Mittwoch, 6. Juni 2012 16:58:23 UTC+2 schrieb Bluemercury:
>
>> Also, there's 2 factors:
>> 1- my DateTimePickerDialogFragment is being included in a different
>> library project, so it will not know the sub type of Fragment being passed.
>> 2- in one target fragment i will need, i have two edittexts in the same
>> fragment so the DateTimePickerDialogFragment must somehow point to the
>> correct edittext
>>
>> regards,
>>
>>
>> On Wednesday, June 6, 2012 2:16:42 PM UTC+1, Bluemercury wrote:
>>>
>>>
>>> Hi al! i've read the answer from Dianne, and it seems i can declare an
>>> interface in one fragment and then implement it on another. But for this i
>>> need the pointer to the fragment in question, she said:
>>>
>>> " take advantage of the FragmentManager APIs to save a fragment
>>> "pointer" in a bundle and later retrieve it, to allow you to maintain
>>> direct pointers across state save/restore. "
>>>
>>> What's the best way to do this? Here's my code to call the
>>> dialogfragment in the main frag:
>>>
>>> "dialFragment=**DateTimePickerDialogFragment.**newInstance(**
>>> DateTimePickerDialogFragment.**DATETIME_PICKER, dateBeginTV);
>>>   dialFragment.show(fragMan, "dialog");"
>>>
>>> how can i send the pointer to the dialogfragment, and will it survive
>>> the rotation?
>>>
>>>
>>> On Wednesday, June 6, 2012 8:20:30 AM UTC+1, al wrote:

 Ok, I assumed that text field was part of the activity. In your case
 https://groups.google.com/**forum/?fromgroups#!topic/**
 android-developers/NBlMJnMaGboshould
  help, especially the answer of Dianne.

 In short: you might just do 
 "dialogfragment.**setTargetFragment(**textfieldfragment)"
 in the activity to link the fragments. Android will then take care of that
 reference. In the dialogFragment you can then pass the new value like
 "((MyFragmentClass)**getTargetFragment()).**
 setDateTimeField(curDateTime()**).


>>>
>>  --
> 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
>

-- 
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

Re: [android-developers] Problem refreshing a fragment edittext view from a dialogFragment after rotation

2012-06-07 Thread al
setTargetFragment / getTargetFragment as per my last reply.

Am Mittwoch, 6. Juni 2012 16:58:23 UTC+2 schrieb Bluemercury:
>
> Also, there's 2 factors:
> 1- my DateTimePickerDialogFragment is being included in a different 
> library project, so it will not know the sub type of Fragment being passed.
> 2- in one target fragment i will need, i have two edittexts in the same 
> fragment so the DateTimePickerDialogFragment must somehow point to the 
> correct edittext
>
> regards,
>
>
> On Wednesday, June 6, 2012 2:16:42 PM UTC+1, Bluemercury wrote:
>>
>>
>> Hi al! i've read the answer from Dianne, and it seems i can declare an 
>> interface in one fragment and then implement it on another. But for this i 
>> need the pointer to the fragment in question, she said:
>>
>> " take advantage of the FragmentManager APIs to save a fragment "pointer" 
>> in a bundle and later retrieve it, to allow you to maintain direct pointers 
>> across state save/restore. "
>>
>> What's the best way to do this? Here's my code to call the dialogfragment 
>> in the main frag:
>>
>> "dialFragment=DateTimePickerDialogFragment.newInstance(DateTimePickerDialogFragment.DATETIME_PICKER,
>>  
>> dateBeginTV);
>>   dialFragment.show(fragMan, "dialog");"
>>
>> how can i send the pointer to the dialogfragment, and will it survive the 
>> rotation?
>>
>>
>> On Wednesday, June 6, 2012 8:20:30 AM UTC+1, al wrote:
>>>
>>> Ok, I assumed that text field was part of the activity. In your case 
>>> https://groups.google.com/forum/?fromgroups#!topic/android-developers/NBlMJnMaGboshould
>>>  help, especially the answer of Dianne.
>>>
>>> In short: you might just do 
>>> "dialogfragment.setTargetFragment(textfieldfragment)" in the activity to 
>>> link the fragments. Android will then take care of that reference. In the 
>>> dialogFragment you can then pass the new value like 
>>> "((MyFragmentClass)getTargetFragment()).setDateTimeField(curDateTime()). 
>>>
>>>  
>>
>

-- 
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

Re: [android-developers] Problem refreshing a fragment edittext view from a dialogFragment after rotation

2012-06-06 Thread Bluemercury
Also, there's 2 factors:
1- my DateTimePickerDialogFragment is being included in a different library 
project, so it will not know the sub type of Fragment being passed.
2- in one target fragment i will need, i have two edittexts in the same 
fragment so the DateTimePickerDialogFragment must somehow point to the 
correct edittext

regards,


On Wednesday, June 6, 2012 2:16:42 PM UTC+1, Bluemercury wrote:
>
>
> Hi al! i've read the answer from Dianne, and it seems i can declare an 
> interface in one fragment and then implement it on another. But for this i 
> need the pointer to the fragment in question, she said:
>
> " take advantage of the FragmentManager APIs to save a fragment "pointer" 
> in a bundle and later retrieve it, to allow you to maintain direct pointers 
> across state save/restore. "
>
> What's the best way to do this? Here's my code to call the dialogfragment 
> in the main frag:
>
> "dialFragment=DateTimePickerDialogFragment.newInstance(DateTimePickerDialogFragment.DATETIME_PICKER,
>  
> dateBeginTV);
>   dialFragment.show(fragMan, "dialog");"
>
> how can i send the pointer to the dialogfragment, and will it survive the 
> rotation?
>
>
> On Wednesday, June 6, 2012 8:20:30 AM UTC+1, al wrote:
>>
>> Ok, I assumed that text field was part of the activity. In your case 
>> https://groups.google.com/forum/?fromgroups#!topic/android-developers/NBlMJnMaGboshould
>>  help, especially the answer of Dianne.
>>
>> In short: you might just do 
>> "dialogfragment.setTargetFragment(textfieldfragment)" in the activity to 
>> link the fragments. Android will then take care of that reference. In the 
>> dialogFragment you can then pass the new value like 
>> "((MyFragmentClass)getTargetFragment()).setDateTimeField(curDateTime()). 
>>
>>  
>

-- 
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

Re: [android-developers] Problem refreshing a fragment edittext view from a dialogFragment after rotation

2012-06-06 Thread Bluemercury

Hi al! i've read the answer from Dianne, and it seems i can declare an 
interface in one fragment and then implement it on another. But for this i 
need the pointer to the fragment in question, she said:

" take advantage of the FragmentManager APIs to save a fragment "pointer" 
in a bundle and later retrieve it, to allow you to maintain direct pointers 
across state save/restore. "

What's the best way to do this? Here's my code to call the dialogfragment 
in the main frag:

"dialFragment=DateTimePickerDialogFragment.newInstance(DateTimePickerDialogFragment.DATETIME_PICKER,
 
dateBeginTV);
  dialFragment.show(fragMan, "dialog");"

how can i send the pointer to the dialogfragment, and will it survive the 
rotation?


On Wednesday, June 6, 2012 8:20:30 AM UTC+1, al wrote:
>
> Ok, I assumed that text field was part of the activity. In your case 
> https://groups.google.com/forum/?fromgroups#!topic/android-developers/NBlMJnMaGboshould
>  help, especially the answer of Dianne.
>
> In short: you might just do 
> "dialogfragment.setTargetFragment(textfieldfragment)" in the activity to 
> link the fragments. Android will then take care of that reference. In the 
> dialogFragment you can then pass the new value like 
> "((MyFragmentClass)getTargetFragment()).setDateTimeField(curDateTime()). 
>
>  

-- 
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

Re: [android-developers] Problem refreshing a fragment edittext view from a dialogFragment after rotation

2012-06-06 Thread al
Ok, I assumed that text field was part of the activity. In your case 
https://groups.google.com/forum/?fromgroups#!topic/android-developers/NBlMJnMaGbo
 
should help, especially the answer of Dianne.

In short: you might just do 
"dialogfragment.setTargetFragment(textfieldfragment)" in the activity to 
link the fragments. Android will then take care of that reference. In the 
dialogFragment you can then pass the new value like 
"((MyFragmentClass)getTargetFragment()).setDateTimeField(curDateTime()). 


Am Dienstag, 5. Juni 2012 17:32:09 UTC+2 schrieb Bluemercury:
>
> Hi al! The thing is here im using  framents, the text field is on the 
> fragment, not on the activity itself. The ideia was to create a dynamic 
> dialofgragment without to mess around with the activity too much, since in 
> this case the fragment is part of a viewpager in the activity. What if i 
> use the   this.setRetainInstance(true);  on the fragment that holds the 
> text field too?
>
> regards,
>
> On Tuesday, June 5, 2012 3:14:58 PM UTC+1, al wrote:
>>
>> Of course I'm guessing, but I think you should change the way you 
>> transfer the new date/time value to the text widget.
>>
>> In the activity, say A1, you create the dialog and give it a reference to 
>> the text field of A1. When the device is rotated, the activity is recreated 
>> (=> A2), but the dialog is not (due to this.setRetainInstance(true);). 
>> I.e. the dialog still references the text field of A1, but you see the 
>> activity A2. That's probably the cause of the observed behavior. As far as 
>> I understand it, the way to go is to add a "setDateTimeField()" method to 
>> the activity and to replace the code in the onClick method of the dialog 
>> with something like 
>> "((MyActivityClass)getActivity()).setDateTimeField(curDateTime()). 
>> GetActivity() will return the current/correct activity since the dialog 
>> will be attached to new activity as part of the configuration change.
>>
>

-- 
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

Re: [android-developers] Problem refreshing a fragment edittext view from a dialogFragment after rotation

2012-06-05 Thread Bluemercury
Hi al! The thing is here im using  framents, the text field is on the 
fragment, not on the activity itself. The ideia was to create a dynamic 
dialofgragment without to mess around with the activity too much, since in 
this case the fragment is part of a viewpager in the activity. What if i 
use the   this.setRetainInstance(true);  on the fragment that holds the 
text field too?

regards,

On Tuesday, June 5, 2012 3:14:58 PM UTC+1, al wrote:
>
> Of course I'm guessing, but I think you should change the way you transfer 
> the new date/time value to the text widget.
>
> In the activity, say A1, you create the dialog and give it a reference to 
> the text field of A1. When the device is rotated, the activity is recreated 
> (=> A2), but the dialog is not (due to this.setRetainInstance(true);). 
> I.e. the dialog still references the text field of A1, but you see the 
> activity A2. That's probably the cause of the observed behavior. As far as 
> I understand it, the way to go is to add a "setDateTimeField()" method to 
> the activity and to replace the code in the onClick method of the dialog 
> with something like 
> "((MyActivityClass)getActivity()).setDateTimeField(curDateTime()). 
> GetActivity() will return the current/correct activity since the dialog 
> will be attached to new activity as part of the configuration change.
>

-- 
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

Re: [android-developers] Problem refreshing a fragment edittext view from a dialogFragment after rotation

2012-06-05 Thread al
Of course I'm guessing, but I think you should change the way you transfer 
the new date/time value to the text widget.

In the activity, say A1, you create the dialog and give it a reference to 
the text field of A1. When the device is rotated, the activity is recreated 
(=> A2), but the dialog is not (due to this.setRetainInstance(true);). I.e. 
the dialog still references the text field of A1, but you see the activity 
A2. That's probably the cause of the observed behavior. As far as I 
understand it, the way to go is to add a "setDateTimeField()" method to the 
activity and to replace the code in the onClick method of the dialog with 
something like 
"((MyActivityClass)getActivity()).setDateTimeField(curDateTime()). 
GetActivity() will return the current/correct activity since the dialog 
will be attached to new activity as part of the configuration change.

-- 
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

Re: [android-developers] Problem refreshing a fragment edittext view from a dialogFragment after rotation

2012-06-04 Thread Fred Niggle
If you post up the relevant code it will help.

On 4 June 2012 11:41, Bluemercury  wrote:

> Hi! Seems replying directly from gmail doesnt refresh this page. so im
> posting again, i changed the property like you said but if i call the
> dialogfragment, rotate the phone and press ok, it wont refresh the
> editext.Only if i call it again, dont rotate, and press ok. The problem
> happens when i rotate with the dialogfragment being visible, if the
> edittext has any value, before i rotate, by default it will show the values
> after rotation correctly , so the issue here lies when i rotate while
> showing the dialogfragment, seems the edittext i pass to it looses the
> connection with the view layout
>
> regards,
>
>
> On Sunday, June 3, 2012 3:14:16 PM UTC+1, Fred Niggle wrote:
>
>> This is caused by the contents of the edittext not being saved when
>> rotated.
>> If the edittext is defined via xml then set
>>
>>  android:freezesText="true"
>>
>> to stop the edittext from loosing its contents upon rotation.
>>
>> Hope this help,
>> Fred
>>
>> On 3 June 2012 01:09, Bluemercury  wrote:
>>
>>> So im adapting my DateTimePickerDialog implementation to a
>>> DialogFragment, and right now it works well, i press the button to show the
>>> dialogfragment choose a date/time value, press ok and it will show on the
>>> fragment's edit text view.
>>> The problem is, if i press the button to show the dialog, then rotate,
>>> everything seems to work well except when i press ok to fill the edittext
>>> view it wont fill it with the choosen value. If i do this again it will
>>> work. Seems the problem is when i rotate the edittext seems to loose the
>>> view relation?
>>> Here's the frapgment that calls the dialog:
>>>
>>> public class MainFragment extends Fragment {

   Button button;

  TextView tv;

@Override

  public View onCreateView(LayoutInflater inflater, ViewGroup container,

  Bundle savedInstanceState) {

   this.setRetainInstance(true);

   View view= inflater.inflate(R.layout.**main_fragment,
> container,false);

   button= (Button) view.findViewById(R.id.**button1);

  tv=(TextView) view.findViewById(R.id.**editText1);

  button.setOnClickListener(new OnClickListener() {

   @Override

  public void onClick(View v) {

  FragmentManager fm = getActivity().**getSupportFragmentManager();

  
 DateTimePickerDialog.**newInstance(**DateTimePickerDialog.DATETIME_**PICKER,tv).show(fm,
> "dialog");

   }

  });

  return view;

  }

 }


> Here's the DateTimePickerDialog main methods:
>>>
>>> public static DateTimePickerDialog newInstance(int type,View view) {
>>>
>>>  DateTimePickerDialog f = new DateTimePickerDialog();
>>>
>>>  f.dialogType=type;
>>>
>>>  f.currCal=Calendar.**getInstance();
>>>
>>>  f.element=view;
>>>
>>>
  Logger.write("**DateTimePickerDialog", "newInstance", Logger.INFO);
>>>
>>>  return f;
>>>
>>>  }
>>>
>>>
  public DateTimePickerDialog() {}
>>>
>>>

  @Override
>>>
>>>  public View onCreateView(LayoutInflater inflater, ViewGroup container,
>>>
>>>  Bundle savedInstanceState) {
>>>
>>>
  this.setRetainInstance(true);
>>>
>>>
  this.getDialog().**requestWindowFeature(STYLE_NO_**TITLE);
>>>
>>>  this.setCancelable(false);
>>>
>>>
  type = null;
>>>
>>>
  switch(dialogType){
>>>
>>>
  case DATE_PICKER:
>>>
>>>  type =inflater.inflate(R.layout.**custom_date_picker_dialog,
 container, false);
>>>
>>>  type.findViewById(R.id.**imagelogo).**setBackgroundResource(R.**
 drawable.ico_popup_data);
>>>
>>>  //fillDialogHeader();
>>>
>>>  dateDialog();
>>>
>>>  break;
>>>
>>>  case TIME_PICKER:
>>>
>>>  type =inflater.inflate(R.layout.**custom_time_picker_dialog,
 container, false);
>>>
>>>  type.findViewById(R.id.**imagelogo).**setBackgroundResource(R.**
 drawable.ico_popup_hora);
>>>
>>>  //fillDialogHeader();
>>>
>>>  timeDialog();
>>>
>>>  break;
>>>
>>>  case DATETIME_PICKER:
>>>
>>>  type =inflater.inflate(R.layout.**custom_datetime_picker_dialog,
 container, false);
>>>
>>>  type.findViewById(R.id.**imagelogo).**setBackgroundResource(R.**
 drawable.ico_popup_datahora);
>>>
>>>  //fillDialogHeader();
>>>
>>>  dateTimeDialog();
>>>
>>>  }
>>>
>>>
  fillDialogHeader();
>>>
>>>  //button clicks
>>>
>>>  ok=(Button)type.findViewById(**R.id.btn_change_date_ok);
>>>
>>>  ok.setOnClickListener(this);
>>>
>>>  clean=(Button)type.**findViewById(R.id.btn_change_**date_clean);
>>>
>>>  clean.setOnClickListener(this)**;
>>>
>>>  cancel=(Button)type.**findViewById(R.id.btn_change_**date_cancel);
>>>
>>>  cancel.setOnClickListener(**this);
>>>
>>>
  Logger.write("**DateTimePickerDialog", "onCreateView", Logger.INFO);
>>>
>>>  return type;
>>>
>>>  }
>>>
>>>
>>> Is the problem associated with passing the edittext view element?
>>>
>>> regards,
>>>

>>>
>>>
>>>
>>>
>

Re: [android-developers] Problem refreshing a fragment edittext view from a dialogFragment after rotation

2012-06-04 Thread Bluemercury
Hi! Seems replying directly from gmail doesnt refresh this page. so im 
posting again, i changed the property like you said but if i call the 
dialogfragment, rotate the phone and press ok, it wont refresh the 
editext.Only if i call it again, dont rotate, and press ok. The problem 
happens when i rotate with the dialogfragment being visible, if the 
edittext has any value, before i rotate, by default it will show the values 
after rotation correctly , so the issue here lies when i rotate while 
showing the dialogfragment, seems the edittext i pass to it looses the 
connection with the view layout

regards,

On Sunday, June 3, 2012 3:14:16 PM UTC+1, Fred Niggle wrote:
>
> This is caused by the contents of the edittext not being saved when 
> rotated.
> If the edittext is defined via xml then set 
>
>  android:freezesText="true"
>
> to stop the edittext from loosing its contents upon rotation.
>
> Hope this help,
> Fred
>
> On 3 June 2012 01:09, Bluemercury  wrote:
>
>> So im adapting my DateTimePickerDialog implementation to a 
>> DialogFragment, and right now it works well, i press the button to show the 
>> dialogfragment choose a date/time value, press ok and it will show on the 
>> fragment's edit text view.
>> The problem is, if i press the button to show the dialog, then rotate, 
>> everything seems to work well except when i press ok to fill the edittext 
>> view it wont fill it with the choosen value. If i do this again it will 
>> work. Seems the problem is when i rotate the edittext seems to loose the 
>> view relation?
>> Here's the frapgment that calls the dialog:
>>
>> public class MainFragment extends Fragment {
>>>
>>>   Button button;
>>>
>>>  TextView tv;
>>>
>>>@Override
>>>
>>>  public View onCreateView(LayoutInflater inflater, ViewGroup container,
>>>
>>>  Bundle savedInstanceState) {
>>>
>>>   this.setRetainInstance(true);
>>>
>>>   View view= inflater.inflate(R.layout.main_fragment, container,false);
>>>
>>>   button= (Button) view.findViewById(R.id.button1);
>>>
>>>  tv=(TextView) view.findViewById(R.id.editText1);
>>>
>>>  button.setOnClickListener(new OnClickListener() {
>>>
>>>   @Override
>>>
>>>  public void onClick(View v) {
>>>
>>>  FragmentManager fm = getActivity().getSupportFragmentManager();
>>>
>>>  
>>> DateTimePickerDialog.newInstance(DateTimePickerDialog.DATETIME_PICKER,tv).show(fm,
>>>  
 "dialog");
>>>
>>>   }
>>>
>>>  });
>>>
>>>  return view;
>>>
>>>  }
>>>
>>> }
>>>
>>>
 Here's the DateTimePickerDialog main methods:
>>
>> public static DateTimePickerDialog newInstance(int type,View view) {
>>
>>  DateTimePickerDialog f = new DateTimePickerDialog();
>>
>>  f.dialogType=type;
>>
>>  f.currCal=Calendar.getInstance();
>>
>>  f.element=view;
>>
>>
>>>  Logger.write("DateTimePickerDialog", "newInstance", Logger.INFO);
>>
>>  return f;
>>
>>  }
>>
>>
>>>  public DateTimePickerDialog() {}
>>
>>
>>>
>>>  @Override
>>
>>  public View onCreateView(LayoutInflater inflater, ViewGroup container,
>>
>>  Bundle savedInstanceState) {
>>
>>
>>>  this.setRetainInstance(true);
>>
>>
>>>  this.getDialog().requestWindowFeature(STYLE_NO_TITLE);
>>
>>  this.setCancelable(false);
>>
>>
>>>  type = null;
>>
>>
>>>  switch(dialogType){
>>
>>
>>>  case DATE_PICKER:
>>
>>  type =inflater.inflate(R.layout.custom_date_picker_dialog, container, 
>>> false);
>>
>>  
>>> type.findViewById(R.id.imagelogo).setBackgroundResource(R.drawable.ico_popup_data);
>>
>>  //fillDialogHeader();
>>
>>  dateDialog();
>>
>>  break;
>>
>>  case TIME_PICKER:
>>
>>  type =inflater.inflate(R.layout.custom_time_picker_dialog, container, 
>>> false);
>>
>>  
>>> type.findViewById(R.id.imagelogo).setBackgroundResource(R.drawable.ico_popup_hora);
>>
>>  //fillDialogHeader();
>>
>>  timeDialog();
>>
>>  break;
>>
>>  case DATETIME_PICKER:
>>
>>  type =inflater.inflate(R.layout.custom_datetime_picker_dialog, 
>>> container, false);
>>
>>  
>>> type.findViewById(R.id.imagelogo).setBackgroundResource(R.drawable.ico_popup_datahora);
>>
>>  //fillDialogHeader();
>>
>>  dateTimeDialog(); 
>>
>>  }
>>
>>
>>>  fillDialogHeader();
>>
>>  //button clicks
>>
>>  ok=(Button)type.findViewById(R.id.btn_change_date_ok);
>>
>>  ok.setOnClickListener(this);
>>
>>  clean=(Button)type.findViewById(R.id.btn_change_date_clean);
>>
>>  clean.setOnClickListener(this);
>>
>>  cancel=(Button)type.findViewById(R.id.btn_change_date_cancel);
>>
>>  cancel.setOnClickListener(this);
>>
>>
>>>  Logger.write("DateTimePickerDialog", "onCreateView", Logger.INFO);
>>
>>  return type;
>>
>>  }
>>
>>
>> Is the problem associated with passing the edittext view element?
>>
>> regards, 
>>
>>>  
>>
>>
>>  
>>
>> -- 
>> 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://

Re: [android-developers] Problem refreshing a fragment edittext view from a dialogFragment after rotation

2012-06-03 Thread Fred Niggle
This is caused by the contents of the edittext not being saved when rotated.
If the edittext is defined via xml then set

 android:freezesText="true"

to stop the edittext from loosing its contents upon rotation.

Hope this help,
Fred

On 3 June 2012 01:09, Bluemercury  wrote:

> So im adapting my DateTimePickerDialog implementation to a DialogFragment,
> and right now it works well, i press the button to show the dialogfragment
> choose a date/time value, press ok and it will show on the fragment's edit
> text view.
> The problem is, if i press the button to show the dialog, then rotate,
> everything seems to work well except when i press ok to fill the edittext
> view it wont fill it with the choosen value. If i do this again it will
> work. Seems the problem is when i rotate the edittext seems to loose the
> view relation?
> Here's the frapgment that calls the dialog:
>
> public class MainFragment extends Fragment {
>>
>>  Button button;
>>
>> TextView tv;
>>
>>  @Override
>>
>> public View onCreateView(LayoutInflater inflater, ViewGroup container,
>>
>> Bundle savedInstanceState) {
>>
>>  this.setRetainInstance(true);
>>
>>  View view= inflater.inflate(R.layout.main_fragment, container,false);
>>
>>  button= (Button) view.findViewById(R.id.button1);
>>
>> tv=(TextView) view.findViewById(R.id.editText1);
>>
>> button.setOnClickListener(new OnClickListener() {
>>
>>  @Override
>>
>> public void onClick(View v) {
>>
>> FragmentManager fm = getActivity().getSupportFragmentManager();
>>
>> DateTimePickerDialog.newInstance(DateTimePickerDialog.DATETIME_PICKER,tv).show(fm,
>>> "dialog");
>>
>>  }
>>
>> });
>>
>> return view;
>>
>> }
>>
>> }
>>
>>
>>> Here's the DateTimePickerDialog main methods:
>
> public static DateTimePickerDialog newInstance(int type,View view) {
>
> DateTimePickerDialog f = new DateTimePickerDialog();
>
> f.dialogType=type;
>
> f.currCal=Calendar.getInstance();
>
> f.element=view;
>
>
>> Logger.write("DateTimePickerDialog", "newInstance", Logger.INFO);
>
> return f;
>
> }
>
>
>> public DateTimePickerDialog() {}
>
>
>>
>> @Override
>
> public View onCreateView(LayoutInflater inflater, ViewGroup container,
>
> Bundle savedInstanceState) {
>
>
>> this.setRetainInstance(true);
>
>
>> this.getDialog().requestWindowFeature(STYLE_NO_TITLE);
>
> this.setCancelable(false);
>
>
>> type = null;
>
>
>> switch(dialogType){
>
>
>> case DATE_PICKER:
>
> type =inflater.inflate(R.layout.custom_date_picker_dialog, container,
>> false);
>
>
>> type.findViewById(R.id.imagelogo).setBackgroundResource(R.drawable.ico_popup_data);
>
> //fillDialogHeader();
>
> dateDialog();
>
> break;
>
> case TIME_PICKER:
>
> type =inflater.inflate(R.layout.custom_time_picker_dialog, container,
>> false);
>
>
>> type.findViewById(R.id.imagelogo).setBackgroundResource(R.drawable.ico_popup_hora);
>
> //fillDialogHeader();
>
> timeDialog();
>
> break;
>
> case DATETIME_PICKER:
>
> type =inflater.inflate(R.layout.custom_datetime_picker_dialog, container,
>> false);
>
>
>> type.findViewById(R.id.imagelogo).setBackgroundResource(R.drawable.ico_popup_datahora);
>
> //fillDialogHeader();
>
> dateTimeDialog();
>
> }
>
>
>> fillDialogHeader();
>
> //button clicks
>
> ok=(Button)type.findViewById(R.id.btn_change_date_ok);
>
> ok.setOnClickListener(this);
>
> clean=(Button)type.findViewById(R.id.btn_change_date_clean);
>
> clean.setOnClickListener(this);
>
> cancel=(Button)type.findViewById(R.id.btn_change_date_cancel);
>
> cancel.setOnClickListener(this);
>
>
>> Logger.write("DateTimePickerDialog", "onCreateView", Logger.INFO);
>
> return type;
>
> }
>
>
> Is the problem associated with passing the edittext view element?
>
> regards,
>
>>
>
>
>
>
> --
> 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




-- 
Magnetic Door Alarm
appis
now available in Google Play

-- 
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