I tried to make a mortgage calc app on my Android Studio.
I really make a class called "Mortgage" on it.
In fact, when I make it on MainActivity.java it not working.
Here is a code:
package com.example.mortgagecalapp;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
mortgage = new Mortgage();
setContentView( R.layout.activity_main );
}
@Override
protected void onStart() {
super.onStart();
updateView();
}
private void updateView() {
TextView amountTV = findViewById(R.id.amountNumber_textView);
amountTV.setText(mortgage.getFormattedAmount());
TextView yearsTV = findViewById(R.id.yearsNumber_textView);
yearsTV.setText("" + mortgage.getYears());
}
public void modifyData(View view) {
Intent myIntenT = new Intent(this, DataActivity.class);
this.startActivity(myIntenT);
}
}
It said Cannot resolve symbol 'mortgage'
, I do not know why it cannot resolve it. I really make mortgage = new Mortgage();
on it.
All the mortgage
is red.
How to fix it, or I got a bug?