我的应用程序中有两个页面,我将一个特定值从一个页面传递到另一个页面:
类级别定义:(来自发送类)
BuyGold50 BG5 = null;
在同一类的 onCreate() 中:
BG5 = new BuyGold50();
在第一个Activity的某个函数中--调用intent到第二个Activity之前
BG5.SetPrice(Gold);
==================================================== ===============================
BuyGold50 类的代码
public class BuyGold50 extends Activity {
public static String B;
static int X;
public void SetPrice(String Price) {
B = Price;
X = Integer.parseInt(B);
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.buy_gold50);
TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText(X);
}
}
原木猫
07-30 11:59:07.304: E/AndroidRuntime(615): FATAL EXCEPTION: main
07-30 11:59:07.304: E/AndroidRuntime(615): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Geet/com.Geet.BuyGold50}: android.content.res.Resources$NotFoundException: String resource ID #0xb34
07-30 11:59:07.304: E/AndroidRuntime(615): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-30 11:59:07.304: E/AndroidRuntime(615): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-30 11:59:07.304: E/AndroidRuntime(615): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-30 11:59:07.304: E/AndroidRuntime(615): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-30 11:59:07.304: E/AndroidRuntime(615): at android.os.Handler.dispatchMessage(Handler.java:99)
07-30 11:59:07.304: E/AndroidRuntime(615): at android.os.Looper.loop(Looper.java:123)
07-30 11:59:07.304: E/AndroidRuntime(615): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-30 11:59:07.304: E/AndroidRuntime(615): at java.lang.reflect.Method.invokeNative(Native Method)
07-30 11:59:07.304: E/AndroidRuntime(615): at java.lang.reflect.Method.invoke(Method.java:507)
07-30 11:59:07.304: E/AndroidRuntime(615): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-30 11:59:07.304: E/AndroidRuntime(615): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-30 11:59:07.304: E/AndroidRuntime(615): at dalvik.system.NativeStart.main(Native Method)
07-30 11:59:07.304: E/AndroidRuntime(615): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0xb34
07-30 11:59:07.304: E/AndroidRuntime(615): at android.content.res.Resources.getText(Resources.java:201)
07-30 11:59:07.304: E/AndroidRuntime(615): at android.widget.TextView.setText(TextView.java:2857)
07-30 11:59:07.304: E/AndroidRuntime(615): at com.Geet.BuyGold50.onCreate(BuyGold50.java:21)
07-30 11:59:07.304: E/AndroidRuntime(615): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-30 11:59:07.304: E/AndroidRuntime(615): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-30 11:59:07.304: E/AndroidRuntime(615): ... 11 more