Activity preview disappears when I add a fragment - android

A screenshot of the activity.xml
The dependencies i have added are the following:
implementation("androidx.fragment:fragment:1.5.5")
implementation("androidx.fragment:fragment-ktx:1.5.5")
I have tried to invalidate the cache, but that did not work.
I basically followed android documentation
Requested error

Related

Android Layout Manager Attributes

[Layout screen as an bug example1While developing my android app I deleted linear layout by selecting it in layout manager by mouse and pressing delete button after that android studio stopped giving me auto complete code suggestions in XML also layout manager is not showing all attributes associated with with a UI component Please guide me how to fix this issue
The xml code might not be in proper format, like missing any closing bracket or something else, first you should check that.
Other steps to try:
Build -> Clean Project -> Rebuild Project
File -> Invalidate Caches and Resatart
File ->Manage IDE Settings -> Restore Default Settings (it will reset your IDE, as if it is newly installed.)

How to disable Android Navigation at res/navigation/nav_graph.xml

I have deleted the Fragment I created and its layout as I don't need it anymore.
But the Fragment keeps coming back except its layout (that is why I'm getting a missing layout.)
I saw it in the res/navigation/nav_graph.xml.
So I decided to delete the whole nav_graph.xml
On my third try, I included the deletion of the following implementation setup:
implementation 'androidx.navigation:navigation-fragment:2.3.2'
implementation 'androidx.navigation:navigation-ui:2.3.2'
But these two returned as well..
What is the trick of totally deleting them for good?
Remove the fragment in the activity xml that contains
android:name="androidx.navigation.fragment.NavHostFragment"
And if you still having the navgraph.xml, remove the startDestination property.
So then, select File -> Invalidate Caches/Restart -> Invalidate Cache & Restart

Android xml layout is greyed out

error
My xml layout in android studio is greyed. I can't add any view into it. Even if I try to add then I can't change any constraint.
Here is my layout code: https://github.com/Aditya425/parse-project/tree/main
Don't Worry about that!
Just Connect your Device with Internet, Close your Project & Re-open it, it will automatically fix.
If not done, try to Sync Project with Gradle Files after reopening.

How can i open sub-library's activity from Parent Project

i am facing some android sub-module or aar lib problem.
I have one parent project and I want to add a different project into the my parent project (containing DI, network, activity, fragment). I think I have added successfully. My workspace looks like below screen shoot.
i also added in app gradle
implementation project(":GaleriDemo")
and added in settings.gradle
But when I try to open a sub-module activity in a click event in the Parent project. It doesn't open properly for some reason.
My library have some basic configuration for build like below screen shoot.
i tried like this to open my sub-module activity
When i clicked the button i am facing above screen shot behavior (like opening same activity in fragment.). But it should be opening my sub-module TestMainActivity, so i think i missed some configuration or some packageName settings. Thanks for your helping
The names of the layout resource in the problem sub-module and the names in the parent projects are the same. When I edit the layout names, my problem was solved.

appcompat_v7 and fragment_main.xml?

I've updated my eclipse and ADT Plugin from v22.3 to v22.6 recently and recognised some big changes. Whenever I create a new Android Application Project there appears a new appcompat_v7 library which wasn't present on v22.3 plugin and also a fragment_main.xml file which as I understand is meant to replace activity_main.xml file. Why is that? Why is the activity_main.xml file not preferred for activity layout directly anymore and why appcompat library is now included in every project as a necessity?
Is there a way to bring back the old way of creating projects without losing anything? By the way, I create projects compatible with Android versions from 2.2 to 4.4.
Fragment is useful for navigating through layouts of activity.for example if you have two different layout for portrait and landscape mode then you can simply navigate though the different fragments.
Secondly,
if you can not even get used to it,just remove the default code from activity_main.xml and and cut the fragment_layout.xml and paste it to activity_main.
Then delete the code related to fragment in MainActivity.java.Then delete the fragment_main.xml file.
Hope it will work.It worked for me.

Categories

Resources