Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
121 views
in Technique[技术] by (71.8m points)

java - Passing a Int value to another class

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);
 }

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");

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...