0
我運行一個論壇,其中安裝了一個shoutbox插件,用戶可以像即時消息一樣相互通話。我決定做出我認爲會是一個快速的應用程序,它將顯示留言箱,以便用戶可以在旅途中進行通話而不是使用瀏覽器。我發現的問題是,它使用android webview的所有效果很好,但是當你嘗試發送一個喊話時,它會出現一個錯誤,說「失敗!」。好像它沒有與實際的留言箱溝通。使用android webview與網站交互
我的問題是可以像這樣使用webview嗎?還是隻能用它來顯示一個沒有實際與之互動的網頁?下面是我的代碼,我正在使用,所以你們可以看到我是否缺少任何東西,如果是這樣,請指出我在正確的方向謝謝。
public class splash extends Activity {
WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState)
{
final Activity mActivity = this;
super.onCreate(savedInstanceState);
// Adds Progrss bar Support
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.mainx);
// Makes Progress bar Visible
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.myforum.com/forums/shoutbox.php");
mWebView.setWebChromeClient(new WebChromeClient()
{
public void onProgressChanged(WebView view, int progress)
{
//Make the bar disappear after URL is loaded, and changes string to Loading...
mActivity .setTitle("Loading...");
mActivity .setProgress(progress * 100); //Make the bar disappear after URL is loaded
// Return the app name after finish loading
if(progress == 100)
{
setTitle(R.string.title);
}
}
});
}
}
感謝您使用您的答案解決了我的問題 – user2150591 2013-03-13 21:00:52
不客氣:-)繼續前進.. – 2013-03-14 03:49:51