Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在活动之间传递整数值-Android_Java_Android - Fatal编程技术网

Java 在活动之间传递整数值-Android

Java 在活动之间传递整数值-Android,java,android,Java,Android,不幸的是,其他被卡住的帖子帮不了我。 当我在选中easy radiobutton时单击按钮时,应用程序停止工作。我不能去看其他活动 发送方: btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(radiobutton_arm_triceps_easy.isChecked()) {

不幸的是,其他被卡住的帖子帮不了我。 当我在选中easy radiobutton时单击按钮时,应用程序停止工作。我不能去看其他活动

发送方:

btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if(radiobutton_arm_triceps_easy.isChecked()) {
                String dene = "my example test";
                int myValue=2;
                Intent intent = new Intent(getApplicationContext(), exercise_arm_triceps_execute.class);
                intent.putExtra("attempt1", myValue );
                startActivity(intent);
            }
        }
    });
接收端:

int receiveValue=getIntent().getIntExtra("attempt1",0);
    textshow.setText(receiveValue);
LOGCAT

04-26 16:52:06.320 31527-31527/com.example.kerem.tutorial_project E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            Process: com.example.kerem.tutorial_project, PID: 31527
                                                                            java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kerem.tutorial_project/com.example.kerem.tutorial_project.exercise_arm_triceps_execute}: android.content.res.Resources$NotFoundException: String resource ID #0x2
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
                                                                                at android.app.ActivityThread.access$800(ActivityThread.java:135)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:136)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5001)
                                                                                at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:515)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                                at dalvik.system.NativeStart.main(Native Method)
                                                                             Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2
                                                                                at android.content.res.Resources.getText(Resources.java:244)
                                                                                at android.support.v7.widget.ResourcesWrapper.getText(ResourcesWrapper.java:52)
                                                                                at android.widget.TextView.setText(TextView.java:3888)
                                                                                at com.example.kerem.tutorial_project.exercise_arm_triceps_execute.onCreate(exercise_arm_triceps_execute.java:28)
                                                                                at android.app.Activity.performCreate(Activity.java:5231)
                                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
                                                                                at android.app.ActivityThread.access$800(ActivityThread.java:135) 
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                at android.os.Looper.loop(Looper.java:136) 
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5001) 
                                                                                at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
                                                                                at dalvik.system.NativeStart.main(Native Method) 
使用


撞车?显示日志刚刚添加!好的,你可以编辑你的问题,现在展示这个:onCreateexercise\u arm\u triceps\u execute.java:28展示这个类的整个onCreate方法谢谢Martin!固定的
textshow.setText(String.valueOf(receiveValue));