好的。我已经看到了无处不在,我的小脑袋也无法理解更好的方式来刷新活动。任何我能理解的建议都会很棒。 :)有没有更好的方法来刷新WebView?
下面是Java代码:
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中
<?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>
我不喜欢的只是重新堆叠活动后,活动的想法。必须有更简单的方法来刷新Web视图。请帮忙。 :)
YOU SOOOO ROCK!非常感谢。它非常完美! WHOO HOOOO !!!! :) – cdg 2010-04-01 20:51:48
现在,如果我只能把它变成一个小部件....:D – cdg 2010-04-02 03:37:06
乔希的答案是正确的。您将继续重新加载相同的网址。 – 2015-03-18 13:53:34