android - How to keep ListView Item Selected when we navigate and again come on the same fragment? -


i have 1 list view in fragment. clicking item keeping selected because used following code in listselected.xml

<item android:state_pressed="true">     <shape android:shape="rectangle">         <solid android:color="#646973" />     </shape>      </item> <item android:state_selected="true">     <shape android:shape="rectangle">         <solid android:color="#646973" />     </shape></item> <item android:state_activated="true">     <shape android:shape="rectangle">         <solid android:color="#646973" />     </shape></item>   <item android:state_accelerated="false">      <shape android:shape="rectangle">         <solid android:color="#646973" />     </shape>  </item> 

but when go 1 fragment , when again visit same fragment removed want that. please me. list view filled dynamically when oncreateview created.

i've met same problem before. can save fragment state this. save view in fragment.

view mylayout=null; public view oncreateview(layoutinflater inflater, viewgroup container,         bundle savedinstancestate) {     if (container == null) {          return null;     }      if(mylayout==null){         //initialize layout here.           mylayout = inflater.inflate(r.layout.frag_layout, container, false);     }       else{           try{            ((viewgroup)mylayout.getparent()).removeview(mylayout);            }catch(exception e){               //an exception thrown when first time trying remove view parent           }      }      return mylayout; } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -