我有一些列表活动,一个导致另一个。每当我按下返回并返回到上一个列表活动,然后再次返回到此活动时,它都会重新执行整个 onCreate 处理。
如何让它记住加载到列表中的数据?
public class Modules extends ListActivity {
PortalHandler portalHandler;
Login login;
ArrayList<String> menuItems;
Document portal;
String portalHtml;
Elements modules;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
menuItems = new ArrayList<String>();
Bundle extras = getIntent().getExtras().getBundle("extras");
portalHtml = extras.getString("portalHtml");
portal = Jsoup.parse(portalHtml);
modules = portal.select(".courselink ");
for (int i = 0; i < modules.size(); i++) {
menuItems.add(modules.get(i).text()
.substring(0, modules.get(i).text().indexOf("(")));
}
setListAdapter(new ArrayAdapter<String>(this, R.layout.modules,
menuItems));
ListView listView = getListView();
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
}
});
}
}