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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.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_Runtime Error - Fatal编程技术网

Java Android:未找到资源异常

Java Android:未找到资源异常,java,android,runtime-error,Java,Android,Runtime Error,我是一个完全的Android开发新手,上课三周了。该程序编译并运行良好,直到我尝试更改任何编辑文本,或滑动seekBar 分配:创建一个抵押计算器应用程序,允许用户输入购买价格、首付金额和利率。根据这些值,应用程序应计算贷款金额,并显示10年、20年和30年期贷款的每月付款。允许用户使用SeekBar选择自定义贷款期限(以年为单位),并显示该自定义贷款期限的每月付款 我只把数字分为几年作为开始,并没有实施利息。目前,它只是一些被输入和存储的东西。但这不是问题所在。当我试图更改第一个编辑文本时,会

我是一个完全的Android开发新手,上课三周了。该程序编译并运行良好,直到我尝试更改任何编辑文本,或滑动seekBar

分配:创建一个抵押计算器应用程序,允许用户输入购买价格、首付金额和利率。根据这些值,应用程序应计算贷款金额,并显示10年、20年和30年期贷款的每月付款。允许用户使用SeekBar选择自定义贷款期限(以年为单位),并显示该自定义贷款期限的每月付款

我只把数字分为几年作为开始,并没有实施利息。目前,它只是一些被输入和存储的东西。但这不是问题所在。当我试图更改第一个编辑文本时,会显示此错误消息

02-10 00:12:14.801    1275-1275/com.example.dakota.de_mortgage E/InputEventSender﹕ Exception dispatching finished signal.
02-10 00:12:14.802    1275-1275/com.example.dakota.de_mortgage E/MessageQueue-JNI﹕ Exception in MessageQueue callback: handleReceiveCallback
02-10 00:12:14.986    1275-1275/com.example.dakota.de_mortgage E/MessageQueue-JNI﹕ android.content.res.Resources$NotFoundException: String resource ID #0x12
        at android.content.res.Resources.getText(Resources.java:274)
        at android.widget.TextView.setText(TextView.java:4122)
        at com.example.dakota.de_mortgage.MainActivity.updateCustom(MainActivity.java:99)
        at com.example.dakota.de_mortgage.MainActivity.access$100(MainActivity.java:18)
        at com.example.dakota.de_mortgage.MainActivity$2.onTextChanged(MainActivity.java:154)
        at android.widget.TextView.sendOnTextChanged(TextView.java:7663)
        at android.widget.TextView.handleTextChanged(TextView.java:7723)
        at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:9440)
        at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:964)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:515)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:454)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:33)
        at android.text.method.NumberKeyListener.onKeyDown(NumberKeyListener.java:121)
        at android.widget.TextView.doKeyDown(TextView.java:5787)
        at android.widget.TextView.onKeyDown(TextView.java:5600)
        at android.view.KeyEvent.dispatch(KeyEvent.java:2609)
        at android.view.View.dispatchKeyEvent(View.java:8338)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2306)
        at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1682)
        at android.app.Activity.dispatchKeyEvent(Activity.java:2699)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2221)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3918)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3880)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3578)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3635)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3611)
        at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3772)
        at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2208)
        at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1849)
        at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1840)
        at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2185)
        at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:143)
        at andro
02-10 00:12:15.161    1275-1275/com.example.dakota.de_mortgage     E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.dakota.de_mortgage, PID: 1275
android.content.res.Resources$NotFoundException: String resource ID #0x12
        at android.content.res.Resources.getText(Resources.java:274)
        at android.widget.TextView.setText(TextView.java:4122)
        at com.example.dakota.de_mortgage.MainActivity.updateCustom(MainActivity.java:99)
        at com.example.dakota.de_mortgage.MainActivity.access$100(MainActivity.java:18)
        at com.example.dakota.de_mortgage.MainActivity$2.onTextChanged(MainActivity.java:154)
        at android.widget.TextView.sendOnTextChanged(TextView.java:7663)
        at android.widget.TextView.handleTextChanged(TextView.java:7723)
        at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:9440)
        at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:964)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:515)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:454)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:33)
        at android.text.method.NumberKeyListener.onKeyDown(NumberKeyListener.java:121)
        at android.widget.TextView.doKeyDown(TextView.java:5787)
        at android.widget.TextView.onKeyDown(TextView.java:5600)
        at android.view.KeyEvent.dispatch(KeyEvent.java:2609)
        at android.view.View.dispatchKeyEvent(View.java:8338)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1600)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2306)
        at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1682)
        at android.app.Activity.dispatchKeyEvent(Activity.java:2699)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2221)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3918)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3880)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3578)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3635)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3476)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3449)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3468)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3611)
        at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3772)
        at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2208)
        at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1849)
        at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1840)
        at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2185)
        at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
        at android.os.MessageQueue.nativePollOnce(Native Me
这是代码

package com.example.dakota.de_mortgage;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.text.TextWatcher;
import android.text.Editable;

public class MainActivity extends ActionBarActivity {

private static final String CUSTOM_YEAR = "CUSTOM_YEAR";
private static final String YEAR_PAY1 = "YEAR_PAY1";
private static final String YEAR_PAY2 = "YEAR_PAY2";
private static final String YEAR_PAY3 = "YEAR_PAY3";

private int currentCustomYear;
private double purchaseGiven;
private double downGiven;
private double interestGiven;
private double moneyRemain;

private TextView customTextView;
private TextView customYearView;
private EditText tenYearResult;
private EditText twntyYearResult;
private EditText thrtyYearResult;
private EditText customYearResult;
private EditText purchaseDown;
private EditText downText;
private EditText interestText;
private SeekBar customSeekBar;



@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    moneyRemain = 0;

    customTextView = (TextView) findViewById(R.id.customTextView);
    customYearView = (TextView) findViewById(R.id.customYearView);
    tenYearResult = (EditText) findViewById(R.id.tenYearResult);
    twntyYearResult = (EditText) findViewById(R.id.twntyYearResult);
    thrtyYearResult = (EditText) findViewById(R.id.thrtyYearResult);
    customYearResult = (EditText) findViewById(R.id.customYearResult);
    purchaseDown = (EditText) findViewById(R.id.purchaseDown);
    downText = (EditText) findViewById(R.id.downText);
    interestText = (EditText) findViewById(R.id.interestText);

    purchaseDown.addTextChangedListener(purchaseWatcher);
    downText.addTextChangedListener(downWatcher);
    interestText.addTextChangedListener(interestWatcher);

    if ( savedInstanceState == null )
    {
        purchaseGiven = 1.0;
        downGiven = 1.0;
        interestGiven = 1.0;
        currentCustomYear = 18;
    }
    else
    {
        purchaseGiven = savedInstanceState.getDouble(YEAR_PAY1);
        downGiven = savedInstanceState.getDouble(YEAR_PAY2);
        interestGiven = savedInstanceState.getDouble(YEAR_PAY3);

        currentCustomYear =
                savedInstanceState.getInt(CUSTOM_YEAR);
    }

    SeekBar customSeekBar = (SeekBar) findViewById(R.id.customSeekBar);
    customSeekBar.setOnSeekBarChangeListener(customSeekBarListener);
}

private void updateStandard()
{
    moneyRemain = purchaseGiven - downGiven;
    tenYearResult.setText(String.format("%.02f", moneyRemain / 10));
    twntyYearResult.setText(String.format("%.02f", moneyRemain / 20));
    thrtyYearResult.setText(String.format("%.03f", moneyRemain / 30));
}


private void updateCustom()
{
    moneyRemain = purchaseGiven - downGiven;
    customYearView.setText(currentCustomYear);

    customYearResult.setText(String.format("%.02f", moneyRemain / currentCustomYear));
}

@Override
protected void onSaveInstanceState(Bundle outState)
{
    super.onSaveInstanceState(outState);

    outState.putInt(CUSTOM_YEAR, currentCustomYear);
    outState.putDouble(YEAR_PAY1, purchaseGiven);
    outState.putDouble(YEAR_PAY2, downGiven);
    outState.putDouble(YEAR_PAY3, interestGiven);
}

private OnSeekBarChangeListener customSeekBarListener =  new SeekBar.OnSeekBarChangeListener()
{
    @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
    {
        currentCustomYear = seekBar.getProgress();
        updateCustom();
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar)
    {
    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar)
    {
    }
};

private TextWatcher purchaseWatcher = new TextWatcher()
{

    @Override
    public void onTextChanged(CharSequence s, int start,
                              int before, int count)
    {

        try
        {
            purchaseGiven = Double.parseDouble(s.toString());
        }
        catch (NumberFormatException e)
        {
            purchaseGiven = 1.0;
        }


        updateStandard();
        updateCustom();
    }

    @Override
    public void afterTextChanged(Editable s)
    {
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,
                                  int after)
    {
    }
};

private TextWatcher downWatcher = new TextWatcher()
{

    @Override
    public void onTextChanged(CharSequence t, int start,
                              int before, int count)
    {
        try
        {
            downGiven = Double.parseDouble(t.toString());
        }
        catch (NumberFormatException e)
        {
            downGiven = 1.0;
        }

        updateStandard();
        updateCustom();
    }

    @Override
    public void afterTextChanged(Editable t)
    {
    }

    @Override
    public void beforeTextChanged(CharSequence t, int start, int count,
                                  int after)
    {
    }
};

private TextWatcher interestWatcher = new TextWatcher()
{

    @Override
    public void onTextChanged(CharSequence s, int start,
                              int before, int count)
    {

        try
        {
            interestGiven = Double.parseDouble(s.toString());
        }
        catch (NumberFormatException e)
        {
            interestGiven = 1.0;
        }


        updateStandard();
        updateCustom();
    }

    @Override
    public void afterTextChanged(Editable s)
    {
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,
                                  int after)
    {
    }
};
}
这里是xml,如果这很重要的话

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="#FFF" android:id="@+id/tableLayout"
android:stretchColumns="1,2,3" android:padding="5dp">

<TableRow android:layout_height="wrap_content"
    android:layout_width="match_parent" android:id="@+id/tableRow0">
    <TextView android:id="@+id/purchase"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Purchase" android:textColor="#000"
        android:gravity="right" android:paddingRight="5dp"></TextView>
    <EditText android:layout_width="wrap_content"
        android:id="@+id/purchaseDown"
        android:layout_height="wrap_content" android:layout_span="3"
        android:inputType="numberDecimal" android:layout_weight="1">
    </EditText>
</TableRow>

//row 9
<TableRow android:layout_height="wrap_content"
    android:layout_width="match_parent" android:id="@+id/tableRow9">
    <TextView android:id="@+id/down"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Down" android:textColor="#000"
        android:gravity="right" android:paddingRight="5dp"></TextView>
    <EditText android:layout_width="wrap_content"
        android:id="@+id/downText"
        android:layout_height="wrap_content" android:layout_span="3"
        android:inputType="numberDecimal" android:layout_weight="1">
    </EditText>
</TableRow>

<TableRow android:layout_height="wrap_content"
    android:layout_width="match_parent" android:id="@+id/tableRow3">
    <TextView android:id="@+id/interest"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Interest" android:textColor="#000"
        android:gravity="right" android:paddingRight="5dp"></TextView>
    <EditText android:layout_width="wrap_content"
        android:id="@+id/interestText"
        android:layout_height="wrap_content" android:layout_span="3"
        android:inputType="numberDecimal" android:layout_weight="1">
    </EditText>
</TableRow>

<TableRow android:layout_height="wrap_content"
    android:layout_width="match_parent" android:id="@+id/tableRow2">
    <TextView android:id="@+id/tenYear"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="10 Years" android:textColor="#000"
        android:gravity="right" android:paddingRight="5dp"></TextView>
    <EditText android:layout_width="wrap_content"
        android:id="@+id/tenYearResult"
        android:layout_height="wrap_content" android:text="0.0"
        android:gravity="center" android:focusable="false"
        android:layout_weight="1" android:textSize="14sp"
        android:cursorVisible="false" android:longClickable="false"
        android:layout_gravity="left">
    </EditText>
</TableRow>

<TableRow android:layout_height="wrap_content"
    android:layout_width="match_parent" android:id="@+id/tableRow1">
    <TextView android:id="@+id/twntyYear"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="20 Years" android:textColor="#000"
        android:gravity="right" android:paddingRight="5dp"></TextView>
    <EditText android:layout_width="wrap_content"
        android:id="@+id/twntyYearResult"
        android:layout_height="wrap_content" android:text="0.0"
        android:gravity="center" android:focusable="false"
        android:layout_weight="1" android:textSize="14sp"
        android:cursorVisible="false" android:longClickable="false"
        android:layout_gravity="left">
    </EditText>
</TableRow>

<TableRow android:layout_height="wrap_content"
    android:layout_width="match_parent" android:id="@+id/tableRow5">
    <TextView android:id="@+id/thrtyYear"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="30 Years" android:textColor="#000"
        android:gravity="right" android:paddingRight="5dp"></TextView>
    <EditText android:layout_width="wrap_content"
        android:id="@+id/thrtyYearResult"
        android:layout_height="wrap_content" android:text="0.0"
        android:gravity="center" android:focusable="false"
        android:layout_weight="1" android:textSize="14sp"
        android:cursorVisible="false" android:longClickable="false"
        android:layout_gravity="left">
    </EditText>
</TableRow>

<TableRow android:layout_height="wrap_content"
    android:layout_width="match_parent" android:id="@+id/tableRow4">
    <TextView android:id="@+id/customTextView"
        android:layout_width="wrap_content" android:text="Custom"
        android:textColor="#000" android:paddingRight="5dp"
        android:gravity="right|center_vertical"
        android:layout_height="match_parent" android:paddingBottom="5dp"
        android:focusable="false"></TextView>
    <SeekBar android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:id="@+id/customSeekBar" android:layout_span="2"
        android:progress="18" android:paddingLeft="8dp"
        android:paddingRight="8dp" android:paddingBottom="5dp"
        android:layout_weight="1"></SeekBar>
    <TextView android:id="@+id/customYearView"
        android:layout_width="wrap_content" android:text="18"
        android:textColor="#000" android:gravity="center_vertical"
        android:layout_height="match_parent" android:paddingLeft="5dp"
        android:paddingBottom="5dp" android:focusable="false"
        android:layout_weight="1"></TextView>
</TableRow>

<TableRow android:layout_height="wrap_content"
    android:layout_width="match_parent" android:id="@+id/tableRow6">
    <EditText android:layout_width="wrap_content"
        android:id="@+id/customYearResult"
        android:layout_height="wrap_content" android:text="0.0"
        android:gravity="center" android:focusable="false"
        android:layout_weight="1" android:textSize="14sp"
        android:cursorVisible="false" android:longClickable="false"
        android:layout_gravity="left">
    </EditText>
</TableRow>
</TableLayout>

//第9行
我花了几个小时试图自己修复它,并寻找解决方案。我不知道我是不是找错地方了,但我已经穷途末路了

谢谢你能给予的任何帮助。如果需要更多信息,请直接询问


编辑:添加了完整的错误消息。

我发现您的代码中有一个错误

请用这条线

customYearView.setText(""+currentCustomYear);
而不是这个

customYearView.setText(currentCustomYear);

因为TextView接受字符串值。

我发现您的代码中有一个错误

请用这条线

customYearView.setText(""+currentCustomYear);
而不是这个

customYearView.setText(currentCustomYear);

因为TextView接受字符串值。

我发现您的代码中有一个错误

请用这条线

customYearView.setText(""+currentCustomYear);
而不是这个

customYearView.setText(currentCustomYear);

因为TextView接受字符串值。

我发现您的代码中有一个错误

请用这条线

customYearView.setText(""+currentCustomYear);
而不是这个

customYearView.setText(currentCustomYear);

因为TextView接受字符串值。

编译代码后,我在第行中发现了错误

customYearView.setText(当前customyear)

其中currentCustomYear是整数值

将你的方法更新到下面

private void updateCustom() {

        moneyRemain = purchaseGiven - downGiven;
        
        customYearView.setText(""+ currentCustomYear);

        customYearResult.setText(String.format("%.02f", moneyRemain
                / currentCustomYear));
    }
崩溃的原因是您在TextView上设置了一个整数值,但TextView只接受字符序列

来自Android文档

public final void setText (CharSequence text)

更多信息可用

编译代码后,我发现了第行中的错误

customYearView.setText(当前customyear)

其中currentCustomYear是整数值

将你的方法更新到下面

private void updateCustom() {

        moneyRemain = purchaseGiven - downGiven;
        
        customYearView.setText(""+ currentCustomYear);

        customYearResult.setText(String.format("%.02f", moneyRemain
                / currentCustomYear));
    }
崩溃的原因是您在TextView上设置了一个整数值,但TextView只接受字符序列

来自Android文档

public final void setText (CharSequence text)

更多信息可用

编译代码后,我发现了第行中的错误

customYearView.setText(当前customyear)

其中currentCustomYear是整数值

将你的方法更新到下面

private void updateCustom() {

        moneyRemain = purchaseGiven - downGiven;
        
        customYearView.setText(""+ currentCustomYear);

        customYearResult.setText(String.format("%.02f", moneyRemain
                / currentCustomYear));
    }
崩溃的原因是您在TextView上设置了一个整数值,但TextView只接受字符序列

来自Android文档

public final void setText (CharSequence text)

更多信息可用

编译代码后,我发现了第行中的错误

customYearView.setText(当前customyear)

其中currentCustomYear是整数值

将你的方法更新到下面

private void updateCustom() {

        moneyRemain = purchaseGiven - downGiven;
        
        customYearView.setText(""+ currentCustomYear);

        customYearResult.setText(String.format("%.02f", moneyRemain
                / currentCustomYear));
    }
崩溃的原因是您在TextView上设置了一个整数值,但TextView只接受字符序列

来自Android文档

public final void setText (CharSequence text)
更多信息可用

使用
customYearView.setText(String.valueOf(currentCustomYear))

使用
customYearView.setText(String.valueOf(currentCustomYear))

使用
customYearView.setText(String.valueOf(currentCustomYear))

使用
customYearView.setText(String.valueOf(currentCustomYear))

嗯,哦-你只是复制了xml文件而没有做任何修改吗?如果是这样,您必须删除第20行的第9行。请将问题发送至:请包含整个错误消息。鉴于错误消息列表行号,请确保您提供的代码与获取错误消息的代码完全匹配。它目前与错误文本中的行号不匹配。我认为@Vivek的答案可以解决您的问题。.呃,哦-您只是复制了xml文件而没有进行任何修改吗?如果是这样,您必须删除第20行的第9行。请将问题发送至:请包含整个错误消息。鉴于错误消息列表行号,请确保您提供的代码与获取错误消息的代码完全匹配。它目前与错误文本中的行号不匹配。我认为@Vivek的答案可以解决您的问题。.呃,哦-您只是复制了xml文件而没有进行任何修改吗?如果是这样,您必须删除第20行的第9行。请将问题发送至:请包含整个错误消息。鉴于错误消息列表行号,请确保您提供的代码与获取错误消息的代码完全匹配。它目前与错误文本中的行号不匹配。我认为@Vivek的答案可以解决您的问题。.呃,哦-您只是复制了xml文件而没有进行任何修改吗?如果是这样,您必须删除第20行的第9行。请将问题发送至:请包含整个错误消息。鉴于错误消息列表行号,请确保您提供的代码与获取错误消息的代码完全匹配。它当前与错误文本中的行号不匹配。我认为@Vivek的答案将解决您的问题。请编辑更多信息。不鼓励只编写代码和“试试这个”答案,因为它们不包含可搜索的内容,也不包含可搜索的内容