Whenever I want to use any resource element in a non-root package, I need to import my own R class(not the Android R class). For instance,
Root package com.example.testand fileMain.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
No need to import R class.
When I create another package com.example.test.somethingand the new class is there Something.java, I need to import my ownR.class
import com.example.test.R;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
This happens automatically when I move the Java file from the root to a package without root.
Why is this so important?
source
share