Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Problem refreshing a fragment edittext view from a dialogFragment after rotation
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joćo Rossa  
View profile  
 More options Jun 4 2012, 10:05 pm
From: Joćo Rossa <joao.ro...@gmail.com>
Date: Tue, 5 Jun 2012 03:05:50 +0100
Local: Mon, Jun 4 2012 10:05 pm
Subject: Re: [android-developers] Problem refreshing a fragment edittext view from a dialogFragment after rotation

Hi! Here's the related code:

DateTimePickerDialogFragment class:

public class DateTimePickerDialogFragment extends DialogFragment implements

>> OnClickListener{

>> public static final int DATE_PICKER=0;

> public static final int TIME_PICKER=1;

> public static final int DATETIME_PICKER=2;

>> private CustomDatePicker datePicker;

> private CustomTimePicker timePicker;

> private CustomDateTimePicker dateTimePicker;

>  private Button ok,clean,cancel;

>> private int dialogType;

> private View element;//element to fill with date/time value

> private Calendar currCal;

> private View type;

>> public static DateTimePickerDialogFragment newInstance(int type,View
>> view) {

> DateTimePickerDialogFragment dF = new DateTimePickerDialogFragment();

> dF.dialogType=type;

> dF.currCal=Calendar.getInstance();

> dF.element=view;

>  *Logger.write("DateTimePickerDialogFragment", "newInstance",
>> Logger.INFO);*

> return dF;

> }

>> public DateTimePickerDialogFragment() {}

>> @Override

> public Dialog onCreateDialog(Bundle savedInstanceState) {

> // TODO Auto-generated method stub

> return super.onCreateDialog(savedInstanceState);

> }

>  @Override

> public View onCreateView(LayoutInflater inflater, ViewGroup container,

> Bundle savedInstanceState) {

>> *Logger.write("DateTimePickerDialogFragment", "onCreateView- BEGIN",
>> Logger.INFO);*

> * *

> * Logger.write("DateTimePickerDialogFragment","edittext view:"+
>> element,Logger.DEBUG);*

>  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_popu p_data);

> 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_popu p_hora);

> 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_popu p_datahora);

> dateTimeDialog();

> }

>> //fill dialog header

> 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("DateTimePickerDialogFragment", "onCreateView- END",
>> Logger.INFO)*;

> return type;

> }

>> @Override

> public void onResume() {

>> super.onResume();

>  *Logger.write("DateTimePickerDialogFragment", "onResume- BEGIN",
>> Logger.INFO);*

>> if(dialogType==DATE_PICKER){

> datePicker.updateDate(

> currCal.get(Calendar.YEAR),

> currCal.get(Calendar.MONTH),

> currCal.get(Calendar.DATE));

> }

>> if(dialogType==TIME_PICKER){

> timePicker.updateTime(

> currCal.get(Calendar.HOUR_OF_DAY),

> currCal.get(Calendar.MINUTE));

> }

>> if(dialogType==DATETIME_PICKER){

> dateTimePicker.updateDateTime(

> currCal.get(Calendar.YEAR),

> currCal.get(Calendar.MONTH),

> currCal.get(Calendar.DATE),

> currCal.get(Calendar.HOUR_OF_DAY),

> currCal.get(Calendar.MINUTE));

> }

>  *Logger.write("DateTimePickerDialogFragment", "onResume- END",
>> Logger.INFO);*

>  }

>> @Override

> public void onDestroyView() {

> *Logger.write("DateTimePickerDialogFragment", "onDestroyView- BEGIN",
>> Logger.INFO);*

> if (getDialog() != null && getRetainInstance())

> getDialog().setOnDismissListener(null);

> super.onDestroyView();

> *Logger.write("DateTimePickerDialogFragment", "onDestroyView- END",
>> Logger.INFO);*

> }

>> @Override

> public void onClick(View button) {

>  *Logger.write("DateTimePickerDialogFragment", "onClick- BEGIN",
>> Logger.INFO);*

> * Logger.write("DateTimePickerDialogFragment","edittext view:"+
>> element,Logger.DEBUG);*

> /////////////

> //ok button//

> /////////////

> if(button.equals(ok)){

> //get focus for ok button

> ok.requestFocus();

> DateTimePickerDialogFragment.this.dismiss();

>> if(dialogType==DATE_PICKER){

> datePicker.clearFocus();

> if(element !=null)

> if(element instanceof EditText)

> ((EditText)element).setText(curDate());

> else

> ((TextView)element).setText(curDate());

> }

> else if(dialogType==TIME_PICKER){

> timePicker.clearFocus();

> if(element !=null)

> if(element instanceof EditText)

> ((EditText)element).setText(curTime());

> else

> ((TextView)element).setText(curTime());

> }

> else

> {

> dateTimePicker.clearFocus();

> if(element !=null)

> if(element instanceof EditText)

> ((EditText)element).setText(curDateTime());

> else

> ((TextView)element).setText(curDateTime());

> }

>> }

> ////////////////

> //clean button//

> ////////////////

> if(button.equals(clean)){

>> DateTimePickerDialogFragment.this.dismiss();

> if(element!=null)

> if(element instanceof EditText)

> ((EditText)element).setText("");

> else

> ((TextView)element).setText("");

> }

> /////////////////

> //cancel button//

> /////////////////

> if(button.equals(cancel)){

> DateTimePickerDialogFragment.this.dismiss();

> }

>  *Logger.write("DateTimePickerDialogFragment", "onClick- END",
>> Logger.INFO);*

> }

> }

Here's the Fragment Class:

public class *MainFragment* extends Fragment {
 Button button;
EditText tv;
 @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
 *Logger.write("MainFragment", "onCreateView - BEGIN",Logger.INFO);*
* Logger.write("MainFragment", "onCreateView -- EditText= "+tv.toString(),
Logger.INFO);*
 this.setRetainInstance(true);
 View view= inflater.inflate(R.layout.main_fragment, container,false);
 button= (Button) view.findViewById(R.id.button1);
tv=(EditText) view.findViewById(R.id.editText1);
 button.setOnClickListener(new OnClickListener() {
 @Override
public void onClick(View v) {
FragmentManager fm = getActivity().getSupportFragmentManager();
 * **Logger.write("MainFragment", "onCreateView:onClick -- EditText=
"+tv.toString(), Logger.INFO);*
 DateTimePickerDialogFragment.newInstance(DateTimePickerDialog.DATETIME_PICK ER,tv).show(fm,
"dialog");
 }

});

 *Logger.write("MainFragment", "onCreateView - END",Logger.INFO);*
return view;

}
}

Here's the log:

1- running the app without calling the dialogfragment:

06-05 01:59:16.956: I/MainFragment(479): onCreateView - BEGIN
06-05 01:59:17.015: I/MainFragment(479):* onCreateView -- EditText=
android.widget.EditText@44f4b4f8*
06-05 01:59:17.036: I/MainFragment(479): onCreateView - END

2- pressing dialog calling button in fragment:

06-05 02:00:06.165: I/MainFragment(479): *onCreateView:onClick -- EditText=
android.widget.EditText@44f4b4f8*
06-05 02:00:06.175: I/DateTimePickerDialogFragment(479): newInstance
06-05 02:00:06.185: I/DateTimePickerDialogFragment(479): onCreateView- BEGIN
06-05 02:00:06.185: D/DateTimePickerDialogFragment(479): *edittext
view:android.widget.EditText@44f4b4f8*
06-05 02:00:06.296: D/CustomDatePicker(479): UpdateDate: 2012/5/5
06-05 02:00:06.296: D/CustomTimePicker(479): updateTime: 2:0
06-05 02:00:06.315: I/DateTimePickerDialogFragment(479): onCreateView- END
06-05 02:00:06.315: I/DateTimePickerDialogFragment(479): onResume- BEGIN
06-05 02:00:06.315: D/CustomDatePicker(479): UpdateDate: 2012/5/5
06-05 02:00:06.315: D/CustomTimePicker(479): updateTime: 2:0
06-05 02:00:06.325: D/CustomTimePicker(479): onTimeChanged: 2:0
06-05 02:00:06.325: D/CustomTimePicker(479): onTimeChanged: 2:0
06-05 02:00:06.325: I/DateTimePickerDialogFragment(479): onResume- END

3- rotate the screen with dialogfragment visible:

06-05 02:01:13.816: I/DateTimePickerDialogFragment(479): onDestroyView-
BEGIN
06-05 02:01:13.846: I/DateTimePickerDialogFragment(479): onDestroyView- END
06-05 02:01:13.856: I/MainFragment(479): onCreateView - BEGIN
06-05 02:01:13.876: I/MainFragment(479): *onCreateView -- EditText=
android.widget.EditText@44f8ae28*
06-05 02:01:13.876: I/MainFragment(479): onCreateView - END
06-05 02:01:13.876: I/DateTimePickerDialogFragment(479): onCreateView- BEGIN
06-05 02:01:13.876: D/DateTimePickerDialogFragment(479):* edittext
view:android.widget.EditText@44f4b4f8*
06-05 02:01:14.015: D/CustomDatePicker(479): UpdateDate: 2012/5/5
06-05 02:01:14.015: D/CustomTimePicker(479): updateTime: 2:0
06-05 02:01:14.015: I/DateTimePickerDialogFragment(479): onCreateView- END
06-05 02:01:14.035: D/CustomTimePicker(479): onTimeChanged: 2:0
06-05 02:01:14.055: D/CustomTimePicker(479): onTimeChanged: 2:0
06-05 02:01:14.075: I/DateTimePickerDialogFragment(479): onResume- BEGIN
06-05 02:01:14.075: D/CustomDatePicker(479): UpdateDate: 2012/5/5
06-05 02:01:14.075: D/CustomTimePicker(479): updateTime: 2:0
06-05 02:01:14.075: D/CustomTimePicker(479): onTimeChanged: 2:0
06-05 02:01:14.085: D/CustomTimePicker(479): onTimeChanged: 2:0
06-05 02:01:14.085: I/DateTimePickerDialogFragment(479): onResume- END
06-05 02:01:14.185: I/DateTimePickerDialogFragment(479): onDestroyView-
BEGIN
06-05 02:01:14.185: I/DateTimePickerDialogFragment(479): onDestroyView- END
06-05 02:01:14.205: I/MainFragment(479): onCreateView - BEGIN
06-05 02:01:14.255: D/dalvikvm(479): GC_FOR_MALLOC freed 6057 objects /
272936 bytes in 49ms
06-05 02:01:14.265: I/MainFragment(479): *onCreateView -- EditText=
android.widget.EditText@44fb51c0*
06-05 02:01:14.265: I/MainFragment(479): onCreateView - END
06-05 02:01:14.265: I/DateTimePickerDialogFragment(479): onCreateView- BEGIN
06-05 02:01:14.265: D/DateTimePickerDialogFragment(479): *edittext
view:android.widget.EditText@44f4b4f8*
06-05 02:01:14.375: D/CustomDatePicker(479): UpdateDate: 2012/5/5
06-05 02:01:14.375: D/CustomTimePicker(479): updateTime: 2:0
06-05 02:01:14.385: I/DateTimePickerDialogFragment(479): onCreateView- END
06-05 02:01:14.385: D/CustomTimePicker(479): onTimeChanged: 2:0
06-05 02:01:14.385: D/CustomTimePicker(479): onTimeChanged: 2:0
06-05 02:01:14.395: I/DateTimePickerDialogFragment(479): onResume- BEGIN
06-05 02:01:14.395: D/CustomDatePicker(479): UpdateDate: 2012/5/5
06-05 02:01:14.395: D/CustomTimePicker(479): updateTime: 2:0
06-05 02:01:14.405: D/CustomTimePicker(479): onTimeChanged: 2:0
06-05 02:01:14.405: D/CustomTimePicker(479): onTimeChanged: 2:0
06-05 02:01:14.405: I/DateTimePickerDialogFragment(479): onResume- END

4- pressing ok button in dialogfragment to refresh edittext in fragment:

06-05 02:02:13.766: I/DateTimePickerDialogFragment(479): onClick- BEGIN
06-05 02:02:13.766: D/DateTimePickerDialogFragment(479):* edittext
view:android.widget.EditText@44f4b4f8*
06-05 02:02:13.776: I/DateTimePickerDialogFragment(479): onClick- END
06-05 02:02:13.866: I/DateTimePickerDialogFragment(479): onDestroyView-
BEGIN
06-05 02:02:13.895: I/DateTimePickerDialogFragment(479): onDestroyView- END

seems after rotation the edittextview in the dialogfragment is still the
old one before rotation....

regards,

On Mon, Jun 4, 2012 at 2:48 PM, Fred Niggle <fred.nig...@googlemail.com>wrote:

> Ok, first insert logging so that you can see what is happening at runtime.
> I'd target the edittext and the fragment areas to logcat mirrors what is
> happening to the data inside your code.

> Second mail back with both your code (updated to output loging) and the
> Logcat output - this will help to narrow the problematic area.

> On 4 June 2012 14:37, Bluemercury <joao.ro...@gmail.com> wrote:

>> *Here's the DialogFragment:*

>> public class *DateTimePickerDialogFragment *extends DialogFragment
>>>> implements OnClickListener{

>>>> public static final int DATE_PICKER=0;

>>>  public static final int TIME_PICKER=1;

>>>  public static final int DATETIME_PICKER=2;

>>>>  private CustomDatePicker datePicker;

>>>  private CustomTimePicker timePicker;

>>>  private CustomDateTimePicker dateTimePicker;

>>>  private Button ok,clean,cancel;

>>>>  private int dialogType;

>>>  private View element;//element to fill with date/time value

>>>  private Calendar currCal;

>>>  private View type;

>>>> public static DateTimePickerDialogFragment *newInstance*(int type,View
>>>> view) {

>>>  DateTimePickerDialogFragment dF = new DateTimePickerDialogFragment();

>>>  dF.dialogType=type;

>>>  dF.currCal=Calendar.getInstance();

>>>  dF.element=view;

>>>   Logger.write("DateTimePickerDialogFragment", "newInstance",
>>>> Logger.INFO);

>>>  return dF;

>>>  }

>>>>  public DateTimePickerDialogFragment() {}

>>>> @Override

>>>  public Dialog onCreateDialog(Bundle savedInstanceState) {

>>>  // TODO Auto-generated method stub

>>>  return super.onCreateDialog(savedInstanceState);

>>>  }

>>>  @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_popu p_data);

>>>  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_popu p_hora);

>>>  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_popu p_datahora);

>>>  dateTimeDialog();

>>>  }

>>>> //fill dialog header

>>>  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("DateTimePickerDialogFragment", "onCreateView",
>>>> Logger.INFO);

>>>  return type;

>>>  }

>>>>  @Override

>>>  public void *onResume*() {

>>>> super.onResume();

>>>> if(dialogType==DATE_PICKER){

>>>  datePicker.updateDate(

>>>  currCal.get(Calendar.YEAR),

>>>  currCal.get(Calendar.MONTH),

>>>  currCal.get(Calendar.DATE));

>>>  }

>>>>  if(dialogType==TIME_PICKER){

>>>  timePicker.updateTime(

>>>  currCal.get(Calendar.HOUR_OF_DAY),

>>>  currCal.get(Calendar.MINUTE));

>>>  }

>>>> if(dialogType==DATETIME_PICKER){

>>>  dateTimePicker.updateDateTime(

>>>  currCal.get(Calendar.YEAR),

>>>  currCal.get(Calendar.MONTH),

>>>  currCal.get(Calendar.DATE),

>>>  currCal.get(Calendar.HOUR_OF_DAY),

>>>  currCal.get(Calendar.MINUTE));

>>>  }

>>>   Logger.write("DateTimePickerDialogFragment", "onResume", Logger.INFO);

>>>  }

>>>> @Override

>>>  public void *onDestroyView*() {

>>>  if (getDialog() != null && getRetainInstance())

>>>  getDialog().setOnDismissListener(null);

>>>  super.onDestroyView();

>>>  Logger.write("DateTimePickerDialogFragment", "onDestroyView",
>>>> Logger.INFO);

>>>  }

>>>> @Override

>>>  public void *onClick*(View button) {

>>>  /////////////

>>>  //ok button//

>>>  /////////////

>>>  if(button.equals(ok)){

>>>  //get focus for ok button

>>>  ok.requestFocus();

>>>  DateTimePickerDialogFragment.this.dismiss();

>>>>  if(dialogType==DATE_PICKER){

>>>  datePicker.clearFocus();

>>>  if(element !=null)

>>>  if(element instanceof EditText)

>>>  ((EditText)element).setText(curDate());

>>>  else

>>>  ((TextView)element).setText(curDate());

>>>  }

>>>  else if(dialogType==TIME_PICKER){

>>>  timePicker.clearFocus();

>>>  if(element !=null)

>>>  if(element instanceof EditText)

>>>  ((EditText)element).setText(curTime());

>>>  else

>>>  ((TextView)element).setText(curTime());

>>>  }

>>>  else

>>>  {

>>>  dateTimePicker.clearFocus();

>>>  if(element !=null)

>>>  if(element instanceof EditText)

>>>  ((EditText)element).setText(curDateTime());

>>>  else

>>>  ((TextView)element).setText(curDateTime());

>>>  }

>>>> Logger.write("DateTimePickerDialogFragment", "onClick- view:"+ element,
>>>> Logger.INFO);

>>>  }

>>>  ////////////////

>>>  //clean button//

>>>  ////////////////

>>>  if(button.equals(clean)){

>>>>  DateTimePickerDialogFragment.this.dismiss();

>>>  if(element!=null)

>>>  if(element instanceof EditText)

>>>  ((EditText)element).setText("");

>>>  else

>>>  ((TextView)element).setText("");

>>>  }

>>>  /////////////////

>>>  //cancel button//

>>>  /////////////////

>>>  if(button.equals(cancel)){

>>>  DateTimePickerDialogFragment.this.dismiss();

>>>  }

>>>  }

>>> }

>> As you can see i pass the editextView in the newInstance method, i dont
>> know if this is the wrong approach.

>> *Here's the fragment that calls the dialogFragment:*

>> public class *ProcessSearchFragment *extends IpdmsCoreFragment
>>>> implements *OnClickListener*{

>>>>  private EditText processNrTV,dateBeginTV, dateEndTV;

>>>  private Button searchBtn;

>>>>  @Override

>>>  public int getInflatableLayoutId() {

>>>  return R.layout.process_search;

>>>  }

>>>> @Override

>>>  public void *initializeFragment*(Bundle savedInstanceState) {

>>>>  super.initializeFragment(savedInstanceState);

>>>  //initialize views

>>>  processNrTV=(EditText) getView().findViewById(R.id.nrprocesso_value);

>>>  dateBeginTV=(EditText) getView().findViewById(R.id.data_inicio_value);

>>>  dateBeginTV.setOnClickListener(this);

>>>  dateEndTV=(EditText) getView().findViewById(R.id.data_fim_value);

>>>  dateEndTV.setOnClickListener(this);

>>>  searchBtn=(Button) getView().findViewById(R.id.search_button);

>>>  }

>>>   @Override

>>>  public void initializeTask() {

>>>   }

>>>  @Override

>>>  public void updateFragmentUI(Object data) {

>>>   }

>>>>  /* (non-Javadoc)

>>>  * @see android.view.View.OnClickListener#onClick(android.view.View)

>>>  */

>>>  @Override

>>>  public void *onClick*(View v) {

>>>   FragmentManager fragMan= getActivity().getSupportFragmentManager();

>>>  DialogFragment dialFragment;

>>>  if(v.equals(dateBeginTV)){

>>>  dialFragment=DateTimePickerDialogFragment.newInstance(DateTimePickerDialogF ragment.DATETIME_PICKER,
>>>> dateBeginTV);

>>>  dialFragment.show(fragMan, "dialog");

>>>  }

>>>  if(v.equals(dateEndTV)){

>>>  dialFragment=DateTimePickerDialogFragment.newInstance(DateTimePickerDialogF ragment.DATETIME_PICKER,
>>>> dateEndTV);

>>>  dialFragment.show(fragMan, "dialog");

>>>  }

>>>   }

>>>> }

>> Here's the *fragment *xml layout:

>> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

>>     android:layout_width="match_parent"

>>     android:layout_height="match_parent"

>>     android:orientation="vertical"

>>     android:padding="6dp">

>> <TextView

>>         android:id="@+id/process_search"

>>         android:layout_height="wrap_content"

>>         android:layout_width="fill_parent"

>>         android:background="#D81921"

>>         android:paddingLeft="2dp"

>>         android:text="Pesquisa de Processo"

>>         android:textColor="@android:color/white"/>

>>     <ScrollView

>>         android:layout_width="fill_parent"

>>     android:layout_height="fill_parent"

>>     android:fillViewport="true">

>>     <LinearLayout

>>         android:layout_width="fill_parent"

>>     android:layout_height="fill_parent"

>>     android:padding="1dp"

>>     android:background="#cccccc">

>>     <LinearLayout

>>         android:layout_width="fill_parent"

>>     android:layout_height="fill_parent"

>>     android:background="@android:color/white"

>>     android:orientation="vertical">

>>     <EditText

>>         android:id="@+id/nrprocesso_value"

>>         android:layout_width="match_parent"

>>         android:layout_height="wrap_content"

>>         android:hint="Nŗ Processo">

>>     </EditText>

>>     <LinearLayout

>>         android:layout_width="match_parent"

>>         android:layout_height="wrap_content" >

>>         <EditText

>>          android:id="@+id/data_inicio_value"

>>          android:layout_width="wrap_content"

>>          android:layout_height="wrap_content"

>>          android:layout_weight="50"

>>          android:hint="De"

>>          android:freezesText="true">

>>     </EditText>

>>     <EditText

>>          android:id="@+id/data_fim_value"

>>          android:layout_width="wrap_content"

>>         android:layout_height="wrap_content"

>>         android:layout_weight="50"

>>          android:hint="Até">

>>     </EditText>

>>     </LinearLayout>

>>     <Button

>>         android:id="@+id/search_button"

>>         android:layout_width="wrap_content"

>>         android:layout_height="wrap_content"

>>         android:text="Procurar" />

>>     <TextView

>>         android:id="@+id/process_search_result"

>>         android:layout_height="wrap_content"

>>         android:layout_width="fill_parent"

>>         android:background="@android:color/darker_gray"

>>         android:paddingLeft="2dp"

>>         android:text="Resultados"

>>         android:textColor="@android:color/white"/>

>>     <ListView

>>         android:id="@+id/process_search_list"

>>         android:layout_width="match_parent"

>>         android:layout_height="match_parent" >

>>     </ListView>

>>     </LinearLayout>

>>  </LinearLayout>

>>  </ScrollView>

>> </LinearLayout>

>> regards,

>> On Monday, June 4, 2012 11:41:49 AM UTC+1, 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 <joao.ro...@gmail.com> 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 <android-developers@googlegroups.com>
>>>>> To unsubscribe from this group, send email to
>>>>> android-developers+**unsubscribe@googlegroups.com<android-developers%2Bunsu bscribe@googlegroups.com>
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/**group/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en>

>>>> --
>>>> Magnetic Door Alarm app<https://play.google.com/store/apps/details?id=com.nds.magneticdooralarm>is 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+unsubscribe@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en

> --
> Magnetic Door Alarm app<https://play.google.com/store/apps/details?id=com.nds.magneticdooralarm>is 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+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.