<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_2main" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ListView android:choiceMode="multipleChoice" android:id="@+id/countriesList" android:layout_width="match_parent" android:layout_height="match_parent" /> <Button android:id="@+id/btnSubmit" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/btnSubmit"> </Button> </LinearLayout> 

Errors in the "design" mode

 Failed to load AppCompat ActionBar with unknown error. Faild to instantiate one or more classes The following classes could not be instantiated: - android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache) - android.support.v7.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache) - android.support.v7.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. If this is an unexpected error you can also try to build the project, then manually refresh the layout. Exception Details java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener Copy stack to clipboard 

What is the problem ?

  • You completely copied the layout here? - Segrei Ulanov
  • @SegreiUlanov, now — yesAhillesius
  • </LinearLayout> ending </LinearLayout> present? - Segrei Ulanov
  • @SegreiUlanov, yes - Ahillesius
  • Did the answer help you? - Segrei Ulanov

1 answer 1

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_2main" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <ListView android:id="@+id/countriesList" android:layout_width="wrap_content" android:layout_height="match_parent" android:choiceMode="multipleChoice" /> <Button android:id="@+id/btnSubmit" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/btnSubmit" /> </LinearLayout> 

Now displayed. I changed the android:layout_height="wrap_content" in LinearLayout.

match_parent - customizes the size of the components.

wrap_content - stretches to fit the screen, or parent.

  • one
    actually the opposite is true: match_parent is the size of the parent container or screen. wrap_content - size by widget content - pavlofff
  • Thank you for correcting - Segrei Ulanov