package gr.mybook.mylistviews;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class Activity2 extends ListActivity {
	String[] items;
	ListView lView;
	ArrayAdapter<String> mListAdapter;

	public Activity2() {
		// TODO Auto-generated constructor stub
	}
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list);
        lView = getListView();
        lView.setChoiceMode(2); 
        lView.setTextFilterEnabled(true);
        items = getResources().getStringArray(R.array.items1);
        //setListAdapter(new ArrayAdapter<String>(this,
        //         android.R.layout.simple_list_item_multiple_choice, items));
         mListAdapter = 
        	    new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, items);
         setListAdapter(mListAdapter);

        Bundle extras=getIntent().getExtras();
        String txt=extras.getString("key");
        for (int pos=0; pos<10; pos++) {
        	
 		   String sValue = lView.getItemAtPosition(pos).toString();
 		   if (txt.equals(sValue)){
 		        
 	 		  Toast.makeText(this, sValue, Toast.LENGTH_SHORT).show();
			 
 			   lView.setItemChecked(pos, true);
 		   }
        }
    }


}
