有没有更好的方式来刷新的WebView?方式、WebView

由网友(Cherish.(珍惜))分享简介:确定。我已经到处看,我的小脑袋只是不明白一个更好的方式来刷新活动。我能理解任何建议将是巨大的。 :)Ok. I have looked EVERYWHERE and my little brain just can't understand a better way to refresh an activity....

确定。我已经到处看,我的小脑袋只是不明白一个更好的方式来刷新活动。我能理解任何建议将是巨大的。 :)

Ok. I have looked EVERYWHERE and my little brain just can't understand a better way to refresh an activity. Any suggestions that I can understand would be great. :)

下面是java code:

Here is the java code:

package com.dge.dges;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;

public class dgeActivity extends Activity {
 WebView mWebView;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings();
        mWebView.loadUrl("http://www.websitehere.php");

        Button newButton = (Button)findViewById(R.id.new_button);
        newButton.setOnClickListener(new View.OnClickListener() {
   public void onClick(View v) {
    Intent intent = new Intent(dgeActivity.this, dgeActivity.class);
    startActivity(intent);
   }
        });

    }
}

这里是main.xml中

And here is the main.xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/RelativeLayout"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="#000000"

>

 <WebView
        android:id="@+id/webview"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:scrollbars="none"

 />

 <Button
  android:id="@+id/new_button"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_alignParentBottom="true"
  android:layout_centerHorizontal="true"
  android:text="Refresh"
 />





</RelativeLayout>

我不喜欢的活动后,只需重新堆积活动的想法。必须有一个简单的方法来刷新的WebView。请帮忙。 :)

I don't like the idea of just re-stacking activity after activity. There has to be an easier way to refresh the webview. Please help. :)

推荐答案

再打电话

mWebView.loadUrl("http://www.websitehere.php");

等品种code会

so the full code would be

newButton.setOnClickListener(new View.OnClickListener() {
   public void onClick(View v) {
    dgeActivity.this.mWebView.loadUrl("http://www.websitehere.php");
   }});

您也可以拨打 mWebView.reload()但要知道这个转播一个网页,如果该请求是POST。

You can also call mWebView.reload() but be aware this reposts a page if the request was POST.

阅读全文

相关推荐

最新文章