F
F
foonfyrick2021-03-12 14:26:58
android studio
foonfyrick, 2021-03-12 14:26:58

Why can't layout be changed? The background has changed, the views are not inserted?

This is how the screen became:
604b499988a17865986613.png
I decided to make 2 layouts for different screen sizes, I created the layout-xxxhdpi folder,
copied the usual layout from the layout folder, and changed the background to green in it. I launched the emulator with a high resolution and the screen turned green, I think, okay, everything works as it should, I launch another emulator with a small screen, it is also green ... I decided to figure out why, deleted the layout-xxxhdpi folder, deleted it along with the layout, run again the emulator, again a green background, I go into the xml file and this is what is in it:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.view.fragments.MainFragment">
</androidx.constraintlayout.widget.ConstraintLayout>

There is no background in it, I think maybe I didn’t delete the folder, I go:
604b4b33e1749686349641.png
I go 10 more times, I check everything line by line.
I think it may not be shown here, I go to show in Explorer, there is nothing.
Okay, I decided to remove the background. Writes - it is used in other places.
604b4c0a441cf868832083.png
But it is used as a background for mipmaps.
Fragments I switch through nav_graph, I go into it: I start
604b4c8997d80946929360.png
the emulator:
604b4cc3293d1255841988.png
I press the button:
604b4cd94f800454585302.png
I create a button in fragment_main (activities in which the magic green background):
Writes in the logs:
E / AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.skeletmvp , PID: 2310
java.lang.NullPointerException: Missing required view with ID: com.example.skeletmvp:id/button2
at com.example.skeletmvp.databinding.FragmentMainBinding.bind(FragmentMainBinding.java:65)
at com.example.skeletmvp.databinding.FragmentMainBinding.inflate(FragmentMainBinding.java:47
) .MainFragment$bindingInflater$1.invoke(MainFragment.kt:12)
at com.example.skeletmvp.ui.view.fragments.MainFragment$bindingInflater$1.invoke(MainFragment.kt:10)
at com.example.skeletmvp.ui.view .fragments.BaseFragment.onCreateView(BaseFragment.kt:23)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2698)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:320)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1187)
at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2224
) )
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1953)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1849)
at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java :413)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
pmagity....

The snippet is bare, all the code is hidden in the base snippet that I inherit from, I created a few more snippets, all work, in any I can create at least as many views, the background changes, I switched on the split screen, checked everything line by line several times, well, everything is the same as everywhere else, maybe I don’t see it, maybe you can see on the screenshots where the error is, why it happens ...
604b5395c536c982859412.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question