Q:

Displaying list of strings in Android

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?

A:

first you need to create a ArrayList that would store all the strings.
String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
    "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
    "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux",
    "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2",
    "Android", "iPhone", "WindowsMobile" };

final ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < values.length; ++i) {
  list.add(values[i]);
}

then you would need to create an adapter from this arraylist
ArrayAdapter adapter = new ArrayAdapter<String>(this,  
      android.R.layout.simple_list_item_1, 
      list);

then you would need to set this adapter on the listview
listview.setAdapter(adapter);

please see this link for a simple list view implementation:
http://androidexample.com/Create_A_Simple_Listview_-_Android_Example/index.php?view=article_discription&aid=65&aaid=90

A:

Here is my simple way of displaying a list.
1 ) Create a class called MySimpleArrayAdapter
public class MySimpleArrayAdapter extends ArrayAdapter<String> {
    private final Context context;
    private final ArrayList<String> values;

    public MySimpleArrayAdapter(Context context, ArrayList<String> values) {
        super(context, R.layout.rowlayout, values);
        this.context = context;
        this.values = values;
    }

    @Override
    public void notifyDataSetChanged() {
        // TODO Auto-generated method stub
        super.notifyDataSetChanged();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View rowView = null;
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.rowlayout, parent, false);

        // Displaying a textview 
        TextView textView = (TextView) rowView.findViewById(R.id.label);
        textView.setText(values.get(position));

        return rowView;
    }

2) Create an xml file in the layout called rowlayout.xml. We have textview because 
we want to display items but you could display an item with an image. Use ImageView tag
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@+id/label"
        android:textSize="30sp" >
    </TextView>

</LinearLayout>

3) Back to your main activity xml file (activity_main). We have your wifiscan list
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearlayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"> 
  <ListView
        android:id="@+id/wifiScanResList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/wifiScanButton" >

 </ListView>
</LinearLayout>

4) Lastly, in your main activity we set the adapter to your list
public class MainActivity extends Activity {

  // The adapter that we gonna use
  MySimpleArrayAdapter adapter;

  // List of wifi results
  ArrayList<String> wifi_results= new ArrayList<String>();

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

        adapter = new MySimpleArrayAdapter(this, wifi_results);
        setListAdapter(adapter);

        getListView().setOnItemClickListener(new OnItemClickListener() {
        @Override
     public void onItemClick(AdapterView<?> parent, View view, int position,long id) {

          // DO something if the user clicked on the item
         }
           });
    }

}

