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
> 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
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to