'How to target "tools:context" to an activity inside a package of my app in Android Studio?
I imported a set of Java classes and their respective layout xml files into my project in Android Studio, I wanted to organize things so I placed the imported classes inside a package which is located inside my project's java folder (com.example.MYPROJECT). Problem is, that the project is giving errors of "unresolved class" from the xml files of the imported classes. The xml files can't seem to locate the Java classes inside the package I made to organize them. Should I not place the imported classes in a package? I'm looking for a cleaner solution to my problem..
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginFeature.HomeActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
In this case, the package name is "LoginFeature", and the imported java class is called HomeActivity. The .LoginFeature part is not red, which I assume the context:tools understands that this exists. But the .HomeActivity part itself is red in tools:context=".LoginFeature.HomeActivity"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|