当我填充我的最后一个字段时,我的应用程序一直停止代码中没有错误要审核

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了当我填充我的最后一个字段时,我的应用程序一直停止代码中没有错误要审核相关的知识,希望对你有一定的参考价值。

我正在尝试使用锻炼课程为家庭作业创建一个应用程序,该锻炼课程将根据执行某些锻炼所花费的时间来计算燃烧的卡路里数量。我的布局就像我想要的那样,模拟器运行正常,直到我输入最后一个(第三个)输入。我仍然是一个新手,我确信我的错误很简单。任何帮助深表感谢!!!

这是我的锻炼课程:


    public class Workout 

        private int totalCalories;
        private float runningTime;
        private float cyclingTime;
        private float walkingTime;

        public Workout( float r, float w, float c)

            setRunning(r);
            setWalking(w);
            setCycling(c);

        

        public void setRunning(float r)
        
            runningTime=r;
        
        public void setCycling(float c)
        
            cyclingTime=c;
        

        public void setWalking(float w)
        
            walkingTime = w;
        

        public float caloriesBurned()
            return runningTime * 350 + walkingTime * 100 + cyclingTime * 50;
        
    

这是我的MainActivity类:


    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.text.Editable;
    import android.text.TextWatcher;
    import android.widget.EditText;
    import android.widget.TextView;


    public class MainActivity extends AppCompatActivity 
        private Workout calCalc;
        private EditText runEditText;
        private EditText walkEditText;
        private EditText cycleEditText;


        @Override
        protected void onCreate(Bundle savedInstanceState) 
            super.onCreate(savedInstanceState);
            calCalc=new Workout(150.0f, 100.0f, 50.0f );
            setContentView(R.layout.activity_main);

            runEditText = (EditText) findViewById(R.id.amount_run);
            walkEditText=(EditText) findViewById(R.id.amount_walk);
            cycleEditText=(EditText) findViewById(R.id.amount_cycle);

            TextChangeHandler tch = new TextChangeHandler();
            runEditText.addTextChangedListener(tch);
            walkEditText.addTextChangedListener(tch);
            cycleEditText.addTextChangedListener(tch);
        

        public void calculate() 
            String runString = runEditText.getText().toString();
            String walkString = walkEditText.getText().toString();
            String cycleString = cycleEditText.getText().toString();

            TextView caloriesBurnedTextView =
                    (TextView) findViewById(R.id.amount_calories);

            try

                float runAmount = Integer.parseInt(runString);
                float walkAmount = Integer.parseInt(walkString);
                float cycleAmount = Integer.parseInt(cycleString);


                calCalc.setRunning(150.0f * runAmount);
                calCalc.setWalking(100.0f * walkAmount);
                calCalc.setCycling(50.0f * cycleAmount);

                float totalCalories = calCalc.caloriesBurned();

                caloriesBurnedTextView.setText((int) totalCalories);

             catch(NumberFormatException nfe) 

            
        

        private class TextChangeHandler implements TextWatcher
        
            public void afterTextChanged(Editable e) 
                calculate();
            
            public void beforeTextChanged(CharSequence s, int start, int count, int after)
            

            
            public void onTextChanged(CharSequence s, int start, int before, int after)
            

            
        

    

输入跑步,步行和骑行的3个区域后,会出现一个“计算”按钮,单击该按钮进行计算并输出燃烧的总卡路里。

这是我的activity_main.xml:


    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.jblearning.caloriesburnedcal2.MainActivity">


        <TextView
            android:id="@+id/label_run"
            style="@style/LabelStyle"
            android:layout_marginTop="100dp"
            android:layout_marginLeft="20dp"
            android:minWidth="150dp"
            android:text="@string/label_run"/>

        <EditText
            android:id="@+id/amount_run"
            style="@style/InputStyle"
            android:layout_marginRight="20dp"
            android:layout_toRightOf="@+id/label_run"
            android:layout_alignBottom="@+id/label_run"
            android:layout_alignParentRight="true"
            android:hint="@string/amount_run_hint"
            android:inputType="numberDecimal"/>

        <TextView
            android:id="@+id/label_walk"
            style="@style/LabelStyle"
            android:layout_marginTop="20dp"
            android:layout_below="@+id/label_run"
            android:layout_alignLeft="@+id/label_run"
            android:layout_alignRight="@+id/label_run"
            android:text="@string/label_walk"/>

        <EditText
            android:id="@+id/amount_walk"
            style="@style/InputStyle"
            android:layout_toRightOf="@+id/label_walk"
            android:layout_alignBottom="@+id/label_walk"
            android:layout_alignRight="@id/amount_run"
            android:hint="@string/amount_walk_hint"
            android:inputType="number"/>

        <TextView
            android:id="@+id/label_cycle"
            style="@style/LabelStyle"
            android:layout_marginTop="20dp"
            android:layout_below="@+id/label_walk"
            android:layout_alignLeft="@+id/label_walk"
            android:layout_alignRight="@+id/label_walk"
            android:text="@string/label_cycle"/>

        <EditText
            android:id="@+id/amount_cycle"
            style="@style/InputStyle"
            android:layout_toRightOf="@+id/label_cycle"
            android:layout_alignBottom="@+id/label_cycle"
            android:layout_alignRight="@id/amount_walk"
            android:hint="@string/amount_cycle_hint"
            android:inputType="number"/>


        <!-- red line -->

        <View
            android:id="@+id/red_line"
            android:layout_below="@+id/label_cycle"
            android:layout_marginTop="20dp"
            android:layout_height="5dip"
            android:layout_width="match_parent"
            android:layout_alignLeft="@id/label_run"
            android:layout_alignRight="@id/amount_run"
            android:background="#FF00"/>

        <TextView
            android:id="@+id/label_calories"
            style="@style/LabelStyle"
            android:layout_marginTop="20dp"
            android:layout_below="@id/red_line"
            android:layout_alignLeft="@id/label_run"
            android:layout_alignRight="@id/label_run"
            android:text="@string/label_calories"/>

        <TextView
            android:id="@+id/amount_calories"
            style="@style/OutputStyle"
            android:layout_alignBottom="@+id/label_calories"
            android:layout_toRightOf="@+id/label_calories"
            android:layout_alignLeft="@id/amount_run"
            android:layout_alignRight="@id/amount_run"/>



        <Button
            style="@style/ButtonStyle"
            android:layout_marginTop="75dp"
            android:layout_centerHorizontal="true"
            android:layout_below="@+id/amount_calories"
            android:text="@string/button_calculate"
            android:onClick="calculate"/>

    </RelativeLayout>

这是我纠正捕获后的Logcat:

2019-04-14 10:25:59.830 946-946/? I/art: Not late-enabling -Xcheck:jni (already on)
2019-04-14 10:25:59.832 946-946/? W/art: Unexpected CPU variant for X86 using defaults: x86
2019-04-14 10:26:00.057 946-946/com.jblearning.caloriesburnedcal2 W/System: ClassLoader referenced unknown path: /data/app/com.jblearning.caloriesburnedcal2-2/lib/x86
2019-04-14 10:26:00.076 946-946/com.jblearning.caloriesburnedcal2 I/InstantRun: starting instant run server: is main process
2019-04-14 10:26:00.232 946-946/com.jblearning.caloriesburnedcal2 W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.support.v4.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.support.v7.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.ViewGroup android.support.v7.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.support.v7.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.support.v7.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void com.jblearning.caloriesburnedcal2.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:22)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6662)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2599)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2707)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1460)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.os.Looper.loop() (Looper.java:154)
2019-04-14 10:26:00.294 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6077)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:866)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:756)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.jblearning.caloriesburnedcal2-2/base.apk", zip file "/data/app/com.jblearning.caloriesburnedcal2-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.jblearning.caloriesburnedcal2-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.jblearning.caloriesburnedcal2-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.jblearning.caloriesburnedcal2-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.jblearning.caloriesburnedcal2-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.jblearning.caloriesburnedcal2-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.jblearning.caloriesburnedcal2-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.jblearning.caloriesburnedcal2-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.jblearning.caloriesburnedcal2-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.jblearning.caloriesburnedcal2-2/split_
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.support.v4.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.support.v7.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.view.ViewGroup android.support.v7.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.support.v7.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.support.v7.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void com.jblearning.caloriesburnedcal2.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:22)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6662)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2599)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2707)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1460)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.os.Looper.loop() (Looper.java:154)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6077)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:866)
2019-04-14 10:26:00.295 946-946/com.jblearning.caloriesburnedcal2 I/art:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:756)
2019-04-14 10:26:00.427 946-957/com.jblearning.caloriesburnedcal2 I/art: Background partial concurrent mark sweep GC freed 13699(1168KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 5MB/9MB, paused 11.367ms total 31.707ms
2019-04-14 10:26:00.491 946-962/com.jblearning.caloriesburnedcal2 I/OpenGLRenderer: Initialized EGL, version 1.4
2019-04-14 10:26:00.491 946-962/com.jblearning.caloriesburnedcal2 D/OpenGLRenderer: Swap behavior 1
2019-04-14 10:26:00.491 946-962/com.jblearning.caloriesburnedcal2 W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2019-04-14 10:26:00.491 946-962/com.jblearning.caloriesburnedcal2 D/OpenGLRenderer: Swap behavior 0
2019-04-14 10:26:00.507 946-962/com.jblearning.caloriesburnedcal2 D/EGL_emulation: eglCreateContext: 0x96cce4e0: maj 2 min 0 rcv 2
2019-04-14 10:26:00.528 946-962/com.jblearning.caloriesburnedcal2 D/EGL_emulation: eglMakeCurrent: 0x96cce4e0: ver 2 0 (tinfo 0xa535d8c0)
2019-04-14 10:26:00.567 946-946/com.jblearning.caloriesburnedcal2 W/art: Before Android 4.1, method int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
2019-04-14 10:26:00.573 946-962/com.jblearning.caloriesburnedcal2 D/EGL_emulation: eglMakeCurrent: 0x96cce4e0: ver 2 0 (tinfo 0xa535d8c0)
答案

根据您的要求“有一个”计算“按钮被点击进行计算并输出燃烧的总卡路里。”

单击按钮实现calculate()方法,而不是afterTextChanged()。

如果问题仍然存在,请按照评论中的要求添加日志。

另一答案

进程:com.jblearning.caloriesburnedcal2,PID:436 android.content.res.Resources $ NotFoundException:字符串资源ID#0xfde8

你不能setText到Int。您需要在setText之前将totalCalories转换为String。

以上是关于当我填充我的最后一个字段时,我的应用程序一直停止代码中没有错误要审核的主要内容,如果未能解决你的问题,请参考以下文章

在我的所有活动中播放背景音乐,并且仅在我的应用未显示时才停止

在 NetBeans(JAVA) 上,当我启动/测试我的程序时,声音文件突然停止播放

为啥 PyCharm 不建议为 django 模型自动填充?

当我在 asp.net 上发布我的网站时,注册/登录停止工作

停止在移动设备上滚动过去最后一个 Div

在哪里以及如何使用片段填充我的标签