Android Studio: New activity opens as blank screen

后端 未结 5 1469
礼貌的吻别
礼貌的吻别 2021-01-11 15:00

Hello!
I\'m just starting in Android Studio. I searched for a matching question but no joy, please yell out if you\'ve seen this one already!

My main activity ha

相关标签:
5条回答
  • 2021-01-11 15:13

    Have you set the layout for your activity in the line setContentView() like this. Here activity_second is the activity layout of my SecondActivity

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

    if not then your activity will show up as blank. Hope this solves your problem.

    0 讨论(0)
  • 2021-01-11 15:20

    Check weather you have set the correct layout for the setContentView() method of your second activity.

    0 讨论(0)
  • 2021-01-11 15:21

    You can just go to dependencies in build.gradle file and add this line there.. & try.

    implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'

    0 讨论(0)
  • 2021-01-11 15:24

    It sometimes happens when instead of overloading

    protected void onCreate(Bundle savedInstanceState) {
    

    you end up overloading

    public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) 
    

    instead. Make sure the onCreate with only savedInstanceState as a argument is overloaded.

    0 讨论(0)
  • 2021-01-11 15:31

    In my case, I changed device in Android Virtual Divice Manager and this fix problem

    0 讨论(0)
提交回复
热议问题