传递一个int值到另一个类 [英] Passing a Int value to another class
问题描述
我有四组在ListView每个单元有四个网址我想在一个web视图加载。当用户选择一个链接直接转到我设置的值,像这样;
I have four groups in a listview each with four url's I want to load in a webView. When the user select a url to goto I set a value like so;
if (position == 0) webb = webb +2;
{
Intent intent = new Intent(this, official.class);
startActivity(intent);
}
我再结转库存的意图转移到web视图类,我已经给每个URL值像这样;
I then carryout the intent to move to the webView class where I have given each url a value like so;
if (webb == 2) mWebView.loadUrl("http://yahoo.com");
if (webb == 3) mWebView.loadUrl("http://www.bbc.co.uk");
但屏幕保持空白,如果我说出它的工作原理official.class内的值。
But the screen stays blank, if I state the value inside the official.class it works.
我怎样才能得到这个值基础上,用户从列表视图中选择传递给另一个类。很抱歉,如果这是很难理解的。
How can I get this value to pass to another class based on the selection the user makes from the listview. Sorry if this is hard to understand.
推荐答案
如果你的问题是如何共享活动之间的数据(如您的韦伯值),那么你可能想看看<一href="http://developer.android.com/reference/android/content/Intent.html#putExtra%28java.lang.String,%20android.os.Bundle%29"相对=nofollow> Intent.putExtra(...)方法。更多信息:
If your question is how to share data between activities (such as your webb value), then you might want to look at the Intent.putExtra(...) methods. More info:
- http://www.brighthub.com/mobile/google-安卓/用品/ 39467.aspx
- 的http://developer.android.com/guide/appendix/faq/commontasks.html#opennewscreen
- http://www.brighthub.com/mobile/google-android/articles/39467.aspx
- http://developer.android.com/guide/appendix/faq/commontasks.html#opennewscreen
这篇关于传递一个int值到另一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!