1
I am developing an application in Android Studio and trying to use a Listview, but when I run the project, the list does not appear in the emulator!
XML CODE
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.tma.carteiravirtual.carteira.tela_inicio"
tools:showIn="@layout/activity_tela_inicio">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lbl_MeuSaldo"
android:id="@+id/btnSaldo"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/lbl_SaldoAtual"
android:id="@+id/lblSaldoAtual"
android:layout_below="@+id/btnSaldo"
android:layout_centerHorizontal="true"
android:layout_marginTop="22dp"
android:textSize="50dp"
android:textColor="#3ea92d" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Saldo atual"
android:id="@+id/textView2"
android:layout_alignBottom="@+id/lblSaldoAtual"
android:layout_toRightOf="@+id/lblSaldoAtual"
android:layout_toEndOf="@+id/lblSaldoAtual" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Saldo total:"
android:id="@+id/textView"
android:layout_below="@+id/lblSaldoAtual"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="36dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/lbl_SaldoTotal"
android:id="@+id/lblSaldoTotal"
android:layout_alignBottom="@+id/textView5"
android:layout_toRightOf="@+id/textView5"
android:layout_toEndOf="@+id/textView5"
android:textColor="#3ea92d" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="R$"
android:id="@+id/textView5"
android:layout_alignBottom="@+id/textView"
android:layout_toRightOf="@+id/textView"
android:layout_toEndOf="@+id/textView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Total gasto:"
android:id="@+id/textView8"
android:layout_below="@+id/textView5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="R$"
android:id="@+id/textView9"
android:layout_alignBottom="@+id/textView8"
android:layout_toRightOf="@+id/textView8"
android:layout_toEndOf="@+id/textView8" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/lbl_TotalGasto"
android:id="@+id/lblTotalGasto"
android:layout_alignTop="@+id/textView8"
android:layout_toRightOf="@+id/textView9"
android:layout_toEndOf="@+id/textView9"
android:textColor="#a60b0b" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Meus gastos:"
android:id="@+id/textView4"
android:layout_below="@+id/textView9"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listGastos"
android:layout_below="@+id/textView4"
android:layout_alignBottom="@+id/bMais"
android:layout_toLeftOf="@+id/bMais"
android:layout_toStartOf="@+id/bMais" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:id="@+id/bMais"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="37dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:id="@+id/bMenos"
android:layout_above="@+id/bMais"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignLeft="@+id/bMais"
android:layout_alignStart="@+id/bMais" />
</RelativeLayout>
Thank you
It would be good if you put the Java code too, more specifically the part that populates the list
– Leonardo Dias
You must necessarily fill in the list for it to appear?
– Gabriel
Yes, it is necessary to fill it, you can fill it with an array created by yourself, just to make it work
– Leonardo Dias
the list is empty, so it will not appear. these ""item 1 subiten 1" is just a demonstration of the appearance at the time Voce builds xml.
– Mr_Anderson