【发布时间】:2015-01-12 01:48:35
【问题描述】:
对于博客阅读器应用程序,当我尝试将活动内的树屋博客站点作为 web 视图查看时,该应用程序工作。但是当我尝试使用 iTunes url 或其他网站时,它不会显示我活动中的内容,而是打开 chrome。现在我不知道这是否正常,还是我必须为此添加一些代码,谢谢。下面是我正在实现 webview 的活动中的代码,谢谢
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);
}
}
【问题讨论】:
标签: android android-layout android-activity webview android-webview