好的。我已經看到了無處不在,我的小腦袋也無法理解更好的方式來刷新活動。任何我能理解的建議都會很棒。 :)有沒有更好的方法來刷新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