对于博客读者的应用程序,当我尝试查看树屋博客网站的活动作为一个web视图里面的应用程序的工作。但是,当我尝试在iTunes URL或其他网站,它不显示我的活动里面的内容,而不是它打开Chrome浏览器。现在,我不知道这是正常的还是我一定要添加一些$ C $下的,谢谢。下面是code的活动我实现了web视图,谢谢
for the blog reader app, the app work when i try to view the treehouse blog site inside of an activity as a webview. But when i try the itunes url or other websites, it doesnt show the content inside of my activity, instead it opens chrome. Now i dont know if this is normal or do i have to add some code for that, thanks. below is the code in the activity i am implementing the webview, thanks
package com.paveynganpi.applestorefeed;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
public class AppleFeedWebViewActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_apple_feed_web_view);
//get the intent from MainListActivity.java
Intent intent = getIntent();
Uri appleFeedUri = intent.getData();
WebView webView = (WebView)findViewById(R.id.webView);
webView.loadUrl(appleFeedUri.toString());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_apple_feed_web_view, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
推荐答案
在web视图有一个空WebViewClient它默认为这种行为(在浏览器中打开链接)。为了让你的导航的WebView内做到这一点:
When the WebView has a null WebViewClient it defaults to this behavior (opening link in a browser). To keep navigations inside of your WebView do this:
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
});
相关推荐
最新文章