Tamam. HERKESİNE baktım ve küçük beynim bir aktiviteyi yenilemenin daha iyi bir yolunu anlayamıyor. Anlayabileceğim herhangi bir öneri harika olurdu. :)WebView yenilemek için daha iyi bir yolu var mı?
İşte java kodu: Burada
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);
}
});
}
}
Ve 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>
Sadece aktivite sonrası aktiviteyi yeniden istifleme fikrini sevmiyorum olduğunu. Web sayfasını yenilemenin daha kolay bir yolu olmalı. Lütfen yardım et. Ayrıca mWebView.reload()
diyoruz ama bu reposts farkında olabilir) böylece tam kod
newButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dgeActivity.this.mWebView.loadUrl("http://www.websitehere.php");
}});
2 olacağını
mWebView.loadUrl("http://www.websitehere.php");
: :) durumda
SİZ SOOOO ROCK !!! Çok teşekkür ederim. Mükemmel çalıştı! WHOO HOOOO !!!! :) – cdg
Şimdi sadece bir widget'a dönüştürebilirsem ....: D – cdg
Josh cevap doğru olanıdır. Aynı URL’yi yeniden yüklemeye devam edecek. –