How to maintaining listView (java/android) -


i have listview in subactivity of app.. when go subactivity main activity , try return subactivity, item of listview disappear.. how fix problem? if close app , restart it, listview empty... why?

my mainactivity:

final arraylist<string> listcron = new arraylist<string>(); .... @override public boolean onoptionsitemselected(menuitem item) {     // handle action bar item clicks here. action bar     // automatically handle clicks on home/up button, long     // specify parent activity in androidmanifest.xml.     int id = item.getitemid();      switch(id) {         case r.id.history:             intent history = new intent(getapplicationcontext(), historyclass.class);              history.putstringarraylistextra("history", listcron);             startactivity(history);             break;          default:             return true;     }     return super.onoptionsitemselected(item); } 

my subactivity:

 @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.history_main);      toolbar mtoolbar = (toolbar) findviewbyid(r.id.toolbar);     setsupportactionbar(mtoolbar);     getsupportactionbar().sethomebuttonenabled(true);     getsupportactionbar().setdisplayhomeasupenabled(true);       intent = getintent();     arraylist<string> cronologia = i.getstringarraylistextra("history");      listview lv = (listview) findviewbyid(r.id.viewcron);     if (cronologia.isempty()) {         cronologia.add("no operations");     }     arrayadapter<string> adapter = new arrayadapter<string>(this, r.layout.listview_layout, cronologia);     lv.setadapter(adapter);   } 

}

my manifest:

<?xml version="1.0" encoding="utf-8"?> 

<uses-permission android:name="android.permission.vibrate"/>  <application     android:allowbackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme">     <activity         android:name=".mainactivity"         android:label="@string/app_name"         android:windowsoftinputmode="statealwayshidden">         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>     <activity android:name=".historyclass"         android:label="@string/history">     <meta-data         android:name="android.support.parent_activity"         android:value=".mainactivity"/>     </activity> </application> 


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -