How to write an xml file on an Android project, or create something (instance) that is programmed to say R.

Asked 1 years ago, Updated 1 years ago, 331 views

Android Studio Arctic Fox | 2020.3.1 Patch 3 I started studying (experimenting) with JAVA grammar.

https://qiita.com/qiiChan/items/5d94ceb99bfc390c6372
Copy the sauce while looking at

public class MainActivity extensions AppCompatActivity{

    // Object
    private Button btnSend;
    private TextView textInput;
    private TextView textOutput;

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

        btnSend=findViewById(R.id.btnSend);
        textInput=findViewById(R.id.textInput);
        textOutput=findViewById(R.id.textOutput);

Will it move?I'm experimenting with the level I'm trying, but I tripped over a few errors, and now I'm stumbling over the following errors.

C:\\example\testapp001\MainActivity.java:22:
ERROR: Cannot find symbol
btnSend=(Button) findViewById (R.id.btnSend);
^ symbols:variable btnSend location:class id

C:\\TestApp001\app\src\main\res\layout\activity_main.xml
If you look inside, you can't find anything defined by a single "R" character. (I never put this file in.)

What does this error mean?

Thank you for your cooperation.

java android android-studio

2022-09-30 21:58

1 Answers

In the layout file res/layout/activity_main.xml

<Button
        android: id="@+id/btnSend"

There is @+id/btnSend.Automatically registers as R.id.btnSend upon build.


2022-09-30 21:58

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.