URL值不会传递到另一个活动
这是一个应用程序获取一个rss.xml文件,并显示主题的标题呐列表视图。当列表视图的项目(课题标题)被点击,它是开放的web视图中Contenurl活动。但页面是空白。它的意思是feedUri未传递价值Contenturl.java 如果我取代feedUri与像 http://google.com 任何地址然后它工作正常。然后,如果我点击列表视图中的任何项目,google.com是开放的web视图(在我的应用程序)。但我怎么可以通过URL值feedUri?我是否需要在Contenurl.java任何改变文件? plz帮助
This is an app which fetch a rss.xml file and shows the topic's headings n a list view.. When an item(topic heading) of listview is clicked, it is opening in webview in Contenurl activity. But the page is blank. It means "feedUri" is not passing the value to Contenturl.java If I replace "feedUri" with any address like http://google.com then it is working fine. Then if i click on any item of listview, google.com is opening in webview (within my app). But how can I pass the url value with "feedUri" ? Do I need to make any change in Contenurl.java file? plz help
这是MainActivity.java的一部分
This is the part of MainActivity.java
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
Uri feedUri = Uri.parse(myRssFeed.getItem(position).getLink());
Intent w = new Intent(this, Contenturl.class);
w.putExtra(org.rss.mywindows.Contenturl.URL,feedUri);
startActivity(w);
下面是Contenturl.java
here is Contenturl.java
public class Contenturl extends Activity {
public static final String URL = "";
private static final String TAG = "WebscreenClass";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contenturl);
String turl = getIntent().getStringExtra(URL);
Log.i(TAG, " URL = "+turl);
WebView webview = new WebView(this);
setContentView(webview);
// Simplest usage: No exception thrown for page-load error
webview.loadUrl(turl);
}
}
使用
use
而不是
w.putExtra(org.rss.mywindows.Contenturl.URL,feedUri);
和你Contenturl活动
and in your Contenturl Activity
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contenturl);
String turl = getIntent().getStringExtra(URL);
Uri feedUri = Uri.parse(turl);
因为你是从第一个活动发送乌里而在另一个活动接受它作为字符串。那么解决方法是它作为字符串从第一个活动发送
because you are sending Uri from first Activity and receiving it as String in another Activity. then solution is send it as String from first activity