public class ShootList extends ListActivity implements OnItemClickListener {
String[] listItems = {"HeadShot", "BodyShot ", "ExtraShot", "Video Take1", "Video Take2", "Video Take3", };
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
setListAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1, listItems));
ListView shot = getListView();
shot.setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int Position, long arg3) {
// TODO Auto-generated method stub
int P = Position;
switch ( P ) {
case 0:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, 1);
break;
case 1:
AlertDialog.Builder alertbox1 = new AlertDialog.Builder(this);
alertbox1.setMessage("BodyShot").show();
break;
case 2:
AlertDialog.Builder alertbox2 = new AlertDialog.Builder(this);
alertbox2.setMessage("ExtraShot").show();
break;
case 3:
Intent Take1 = new Intent("android.media.action.VIDEO_CAPTURE");
startActivityForResult(Take1, 0);
break;
case 4:
AlertDialog.Builder alertbox4 = new AlertDialog.Builder(this);
alertbox4.setMessage("Take2").show();
break;
case 5:
AlertDialog.Builder alertbox5 = new AlertDialog.Builder(this);
alertbox5.setMessage("Take3").show();
break;
default:
break;
}
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
int i;
// if Activity was canceled, display a Toast message
if (resultCode == RESULT_CANCELED) {
Toast toast = Toast.makeText(this,"camera cancelled", 10000);
toast.show();
return;
}
// lets check if we are really dealing with a picture
if (requestCode == 1 && resultCode == RESULT_OK)
{
Bundle extras = data.getExtras();
Bitmap b = (Bitmap) extras.get("data");
//setContentView(R.layout.main);
ImageView mImg;
mImg = (ImageView) findViewById(R.id.img);
mImg.setImageBitmap(b);
// save image to gallery
String timestamp = Long.toString(System.currentTimeMillis());
MediaStore.Images.Media.insertImage(getContentResolver(), b, timestamp, timestamp);
}
}
}