错误:链接文件资源失败?

时间:2018-04-08 15:01:00

标签: android

您好我是学生/新手并尝试过所有解决方案,但似乎无法将我的代码编译好....

MainActivity

package clune2.declan.gmail.com.simpleinterestcalculator;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private EditText enteredAmout;
    private SeekBar seekBar;
    private Button calculateButton;
    private TextView totalResultTextView;
    private TextView textViewSeekbar;
    private int seekbarPercentage;
    private float enteredPrincipalFloat;
    private TextView totalInterestTv;

    public static final String TAG = "MainActivity";

    public MainActivity(float enteredPrincipalFloat) {
        this.enteredPrincipalFloat = enteredPrincipalFloat;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        enteredAmout = (EditText) findViewById(R.id.billAmountID);
        seekBar = (SeekBar) findViewById(R.id.percentageSeekBar);
        calculateButton = (Button) findViewById(R.id.calculateButton);
        totalResultTextView = (TextView) findViewById(R.id.resultID);
        textViewSeekbar = (TextView) findViewById(R.id.textViewSeekbar);
        totalInterestTv = (TextView) findViewById(R.id.totalBillTextView);

        Toast.makeText(getApplication(), "Hello", Toast.LENGTH_LONG).show();







        calculateButton.setOnClickListener(this);


        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

                textViewSeekbar.setText(String.valueOf(seekBar.getProgress()) + "%");




            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

                seekbarPercentage = seekBar.getProgress();


            }
        });


    }

    @Override
    public void onClick(View v) {
        calculate();

        //TODO: Fix this code
        //TODO: Build amazing application with this example

    }

    public void calculate() {

        float result =  0.0f;

        if (!enteredAmout.getText().toString().equals("")) {

            enteredPercentageFloat = Float.parseFloat(enteredAmout.getText().toString());
            result = enteredPercentageFloat * seekbarPercentage / 100;
            totalResultTextView.setText("Your interest will be" + " $"+String.valueOf(result) );
            totalInterestTv.setText("Total Paid: " + " $"+String.valueOf(enteredBillFloat + result));

            Log.v(TAG, String.valueOf(result));


        }else {
            Toast.makeText(MainActivity.this, "Please enter a bill amount.", Toast.LENGTH_LONG).show();
        }



    }
}

menus.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="clune2.declan.gmail.com.simpleinterestcalculator.SimpleInterestCalculator">
    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:title="@string/action_settings"  
        app:showAsAction="never" />
</menu>

'无法解析符号'错误信息出现在android:title =“@ string / action_settings”的menu.xml文件中....我认为这可能是问题的一部分......

知道我哪里错了吗?

谢谢!

0 个答案:

没有答案