开发者

Embedding webviews in tabs

开发者 https://www.devze.com 2023-02-14 18:55 出处:网络
I got my webview embedded but now I cannot make a back button for them because my webview is declared in the oncreate method and if i declare it in the class i get a force close.. here is my code:

I got my webview embedded but now I cannot make a back button for them because my webview is declared in the oncreate method and if i declare it in the class i get a force close.. here is my code:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ProgressDialog pd = ProgressDialog.show(Twitter.this, "", 
            "Loading. Please wait...", true);


    WebView webview1 = new WebView(this);
    webview1.getSettings().setJavaScriptEnabled(true);
    webview1.getSettings().setPluginsEnabled(true);
    webview1.setWebViewClient(new HelloWebViewClient(pd));
    webview1.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY) ;

When I use the code for a back button in开发者_如何学Go webview, it does not read webview1


Code doesn't go in xml at all.

Since each of the screens available from the tabs is its own activity, don't forget to add it to the manifest file (or it will force close). The code to manipulate these activities goes in their own file.

Notice from the tutorial where it says:

intent = new Intent().setClass(this, ArtistsActivity.class);

The 'ArtistsActivity' there is a separate class with its own file. You'll want to create one of those, and give it its own layout.xml file as well (if you need one).


Hi I am the OP and this issue is solved I just needed to add super.onpause in my method, thanks for your time hydrangea

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号