Displaying list of strings in Android

Viewed 25448

I started developing for Android yesterday, so I am a complete newbie. I am using ADT bundle that works with Eclipse. What I want to do is I have got an array of strings. I would like to display them in a scroll supported view. I found ListView can do that but all tutorials that I found are extremely complex and explaining nested views.

I tried using ListView but I cannot even see the dummy view. Here is what I have tried: activity_main.xml:

<ListView
        android:id="@+id/wifiScanResList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/wifiScanButton" >
</ListView>

in MainActivity Class:

private ListView wifiListView;

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.

    getMenuInflater().inflate(R.menu.main, menu);
    wifiListView = (ListView) findViewById(R.id.wifiScanResList);
    wifiListView.setEnabled(true);

    return true;
}

I have got two questions in regards to my problem now.

First one is, am I using the right view for my needs? If not what should I use?

Second one is, what is the reason that dummy view does not appear? Also how can I simply add strings into ListView?

2 Answers
Related