Android - reuse Activity instance
I have two Activity, Main and Rbrowser Activity. In Main Activity a list of urls is shown. When a link is clicked, Rbrowser Activity is launched. For each launch s开发者_如何转开发etContentView(R.layout.rbrowser);
is called from onCreate
, which is slow.
Is there any good practice to reuse Activity's instance, and just reload Rbrowser's webview with new url?
Thanks
Your problem is not the setContentView(), it can't make an app slow, it is executed in microseconds even on the slowest of devices. Are you loading some ArrayLists or HashMaps or any other bulky variable in the memory in the onCreate() ? If yes, try doing that in a seprate thread or via an AsyncTask.
You coud override the onBackPressed: Android - How To Override the "Back" button so it doesn't Finish() my Activity?
Inside, setVisbility(View.GONE) on your webview, then when someone clicks the link ,set the visibility to visible and load the new url.
精彩评论