Android Studio - MainActivity.java: error: cannot find symbol - class TextView, class View
Hi,
I'm learning to program for Android, I use Android Studio. I have some java code - in the MainActivity.java file I have this code at the beginning:
and when i want to run it, i have an error:
and other bugs:
Please help. Thank you!
Hi,
error in Android Studio - "error: cannot find symbol private TextView display;" will probably mean that you have not imported any libraries, the following should suffice:
I'm learning to program for Android, I use Android Studio. I have some java code - in the MainActivity.java file I have this code at the beginning:
public class MainActivity extends AppCompatActivity {
private TextView display;
private View toDeg;
.....
and when i want to run it, i have an error:
\ .... \ e \ MainActivity.java: 9: error: cannot find symbol
private TextView display;
^
symbol: class TextView
location: class MainActivity
and other bugs:
\ .... \ e \ MainActivity.java: 10: error: cannot find symbol
public void toDeg (View sender) {
^
symbol: class View
location: class MainActivity
\ .... \ e \ MainActivity.java: 29: error: cannot find symbol
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
^
symbol: variable ActivityInfo
location: class MainActivity
\ .... \ e \ MainActivity.java: 46: error: cannot find symbol
Button btn = (Button) sender;
^
symbol: class Button
location: class MainActivity
\ .... \ e \ MainActivity.java: 163: error: cannot find symbol
Toast.makeText (this, "Cant do this", Toast.LENGTH_LONG) .show ();
^
symbol: variable Toast
location: class MainActivity
\ .... \ e \ MainActivity.java: 263: error: cannot find symbol
DecimalFormat decformat = new DecimalFormat ("#. ##");
^
symbol: class DecimalFormat
location: class MainActivity
Please help. Thank you!
REPLY
Hi,
error in Android Studio - "error: cannot find symbol private TextView display;" will probably mean that you have not imported any libraries, the following should suffice:
import android.widget.TextView;
import android.view.View;
import android.content.pm.ActivityInfo;
import android.widget.Button;
import android.widget.Toast;
import java.text.DecimalFormat;