Saturday 15 February 2014

android - Inflate rows dynamically but strange behavior when the orientation of the device is changed -


I'm trying to grow my lines dynamically, but when I change the orientation of the tablet, all of me Some are unselected and the checkbox name is full of last line information, for example, let's say that I have two checkboxes (two lines) first one says "hello" and the other says "good bye." If I rotate the tablet then I will get the first and second checkbox with the name "good alias" and no selection was made. & lt; ScrollView Android: layout_width = "match_parent" Android: layout_height = "match_parent" & gt; & Lt; TableLayout Android: id = "@ + id / tablelayoutlist" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" /> & Lt; / Scrollview & gt;

I have my line defined as (mRowLayout.xml):

   & Lt; / TableRow & gt;   

And then I use the following code to keep my line up:

  Private Zero fillTable (see V, cursor C) {TableLayout Ll = (TableLayout) v.findViewById (R.id.tableLayoutList); MTableRow = Null; Int i = 0; While (! C.isAfterLast ()) {i ++; See MTableRow = (tablerows). Float (getActivity (), R.Lay Out.MR Lowlight, empty); Check box CB = (checkbox) mTableRow.findViewById (R.id.checkBoxServEmail); Logs. E ("debugging", "email:" + c.getstring (c.getColumnIndex (Serv.EMAIL)); Cb.setText (c.getString (c.getColumnIndex (Serv.EMAIL)); MTableRow.setTag (i); // Add TableRows to TableLayout ll.addView (mTableRow); C.moveToNext (); }}   

Does anyone know why I have this weird behavior? Also note that I have logged into logging, which is being printed in my log cat. And I get "Hello" and "good goodbye", every time I change the orientation of my device, but the settext does not work properly.

Please help, I have gone for hours with this issue and I do not get it: (

The activity has been deleted when you change the device orientation.

  onSaveInstanceState   to save your current UI data 

Use the callback to restore it. Use it on the Create To Restore:

  If (Saved InstantState == Free) {// First Run} Other {// First No}    

No comments:

Post a Comment