Android R.java error..

Asked 2 years ago, Updated 2 years ago, 23 views

Android R.java question.

From RegisterActivity

There's an error. The photo and the source code and source code. Please.

package com.example.happy.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.R;
import android.R.*;
public class RegisterActivity extends AppCompatActivity {

    private ArrayAdapter adapter;
    private Spinner spinner;


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

        spinner = (Spinner) findViewById(R.id.majorSpinner);
        adapter = ArrayAdapter.createFromResource(this. R.array.major, android.R.layout.simple_spinner_dropdown_item);
        spinner .setAdapter(adapter);
    }
}

android r.java

2022-09-22 12:00

2 Answers

Have you tried rebuilding project?


2022-09-22 12:00

If you look at the import, the project's R file is not imported, but only the android.R file is imported. You must import the project's R file. The reason why the project's R file cannot be imported is because there is an error in the resource file in the res folder. Check the activity_register.xml file for errors~


2022-09-22 12:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.