Need help with android WebView
I am new to Android and java dev开发者_高级运维elopment. I create a WebView object in the OnCreate function. Now I need to be able to pass this same object to other functions in the code, such as the onOptionsItemSelected function. I currently have it where I just create a new WebView object in each function where I need it, but this slows down the code since it has to recreate it and such.
Something as simple as this?
public class MyActivity extends Activity {
WebView wv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
wv = new WebView(this);
setContentView(wv);
@Override
public boolean onOptionsItemSelected(MenuItem item){
wv.doSomething();
}
精彩评论