Why is my ListView showing only one row?

0

I have a ListView but only one line is showing up, and I am registering 5 data (item 1, item 2 ...) Does anyone know what's going on and what can I do?

Activity.java

public class HomeOrcamentoActivity extends Activity {

private ListView lv1;

private String lv_arr[] = {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"};

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_home_orcamento);

    lv1 = (ListView) findViewById(R.id.listView);

    lv1.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, lv_arr));

    lv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view,
                                int position, long id) {
            switch( position )
            {
                case 0:  Intent newActivity = new Intent(HomeOrcamentoActivity.this, HomeReformasEReparosActivity.class);
                    startActivity(newActivity);
                    break;
                case 1:  Intent newActivity2 = new Intent(HomeOrcamentoActivity.this, WelcomeActivity.class);
                    startActivity(newActivity2);
                    break;
            }
        }
    });
}
}

Activity.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#F3F3F3">


<ListView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/listView"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

</RelativeLayout>
    
asked by anonymous 05.05.2015 / 19:11

1 answer

0

The problem is that your RelativeLayout has a height set to 48dp

Change the line:

android:layout_height="48dp"

To:

android:layout_height="wrap_content"
    
05.05.2015 / 19:36