sinan yılmaz
sinan yılmaz

Reputation: 163

My ListView does not show

My ListView is not visible in my application.
The ListView is added in the layout file as below, but the emulator shows it as an image.

enter image description here

<android.support.constraint.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="com.example.yds.Pages.CokCikanListActivity"
>
<CheckBox
    android:id="@+id/checkboxYapildimi"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="center"
    android:color="#3bbdfa"
    android:focusable="false"
    android:focusableInTouchMode="false" />
<ListView
    android:id="@+id/listViewCCList"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:divider="#ffffff"
    android:dividerHeight="1dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_weight="0.44" />
</android.support.constraint.ConstraintLayout>

Upvotes: 1

Views: 65

Answers (3)

You are missing the content structure of your xml. Transform it into the following:

<android.support.constraint.ConstraintLayoutxmlns: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="com.example.yds.Pages.CokCikanListActivity"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">

<CheckBox
    android:id="@+id/checkboxYapildimi"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="center"
    android:color="#3bbdfa"
    android:focusable="false"
    android:focusableInTouchMode="false" />

<ListView
    android:id="@+id/listViewCCList"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:divider="#ffffff"
    android:dividerHeight="1dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_weight="0.44" />

 </LinearLayout>

Upvotes: 1

Koushik Shom Choudhury
Koushik Shom Choudhury

Reputation: 856

Until you add any item, listview will remain blank and hence you won't see anything. In XML preview the listview is shown as in your image but in the real app it remains blank. Add some item to the list and then you'll be able to see the list.

Upvotes: 0

user8037477
user8037477

Reputation:

emulator show you an image to make you understand how it will be when you will insert some object, but it's only an example, when you will run the apk, it will not show you anything... if you want to insert object, you have to do it in java class

Upvotes: 0

Related Questions