如何從1類方法傳遞值到另一個班級活動的Android/Java的獲得價值從其他類方法
強大的文本
public class A extends Activity{
int value;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
.
.
.
methodA();
}
public void methodA(){
if (condition){
value =1
}
else if (condition){
value =2
}
else{
value =3
}
}
}
}
B類
Public class B extends Activity{
protected void onCreate(Bundle savedInstanceState){
int val;
super.onCreate(savedInstanceState);
.
.
//how do we can get val = value
}
}
問題是B級的val
如何得到A級的value
,將意圖爲這些條件工作?
可能您正在尋找http://stackoverflow.com/questions/3510649/how-to-pass-a-value-from-one-activity-to-another-in-android – guptakvgaurav
http:// stackoverflow。 com/questions/2906925/android-how-do-i-pass-an-object-from-one-activity-to-another – Maxime