package csu.matos.listvidedemo1;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class ListViewDemo1 extends ListActivity {

	String[] items = { "Data-0", "Data-1", "Data-2", "Data-3", 
			           "Data-4", "Data-5", "Data-6", "Data-7" };
	
	// try this empty list later:  
	// String[] items = {};
	
	TextView txtMsg;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list_view_demo1);

		setListAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, android.R.id.text1, items));

		txtMsg = (TextView) findViewById(R.id.txtMsg);
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		String text = " Position: " + position + "   " + items[position];
		txtMsg.setText(text);
	}

}
