package com.samples.hardware.osinfo;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class OsInfoListActivity extends ListActivity {
	private String[] items;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		items = new String[] {
				getResources().getString(R.string.os_version_info),
				getResources().getString(R.string.cpu_info),
				getResources().getString(R.string.memory_info),
				getResources().getString(R.string.disc_space_info)
			};
		
		setListAdapter(new ArrayAdapter<String>(getApplicationContext(),
				android.R.layout.simple_list_item_1, items));
	}
	
	@Override
	protected void onListItemClick(
			ListView parent, View v, int position, long id) {
		try {
			String item = items[position];
	
			Intent intent = new Intent(getApplicationContext(), 
					OsInfoItemActivity.class);
			intent.setAction(item);
			startActivity(intent);
		}
		catch (Exception e) {
			Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
		}
	}
	
}
