How to usemultiple image buttons to take picture and set image?
<p>Hi I am trying to have 6 image buttons that when clicked open camera take pic and set image to that corresponding imageview?  I figured out how to do this with one image buttons, how can I achieve this with mutiple image buttons?  Here is what I have:</p>

<pre><code>public class Post extends Activity implements OnClickListener {

    ImageButton ibutton1;
    ImageButton ibutton2;
    ImageButton ibutton3;
    ImageButton ibutton4;
    ImageButton ibutton5;
    ImageButton ibutton6;


    Intent i1;
    Intent i2;
    Intent i3;
    Intent i4;
    Intent i5;
    Intent i6;

    final static int cameraData1 = 1;
    final static int cameraData2 = 2;
    final static int cameraData3 = 3;
    final static int cameraData4 = 4;
    final static int cameraData5 = 5;
    final static int cameraData6 = 6;

    Bitmap bmp;

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

        Button button = (Button) findViewById(R.id.bNext);
        button.setOnClickListener(mNextListener);

        // Category spinner set up
        Spinner cSpinner = (Spinner) findViewById(R.id.spCategoryPost);
        ArrayAdapter&lt;CharSequence&gt; adapter2 = ArrayAdapter.createFromResource(
                this, R.array.category_array,
                android.R.layout.simple_spinner_item);
        adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        cSpinner.setAdapter(adapter2);

        cSpinner.setOnItemSelectedListener(new MyOnItemSelectedListener2());
        initialize();
    }

    private void initialize() {
        ibutton1 = (ImageButton) findViewById(R.id.imageButton1);
        ibutton2 = (ImageButton) findViewById(R.id.imageButton2);
        ibutton3 = (ImageButton) findViewById(R.id.imageButton3);
        ibutton4 = (ImageButton) findViewById(R.id.imageButton4);
        ibutton5 = (ImageButton) findViewById(R.id.imageButton5);
        ibutton6 = (ImageButton) findViewById(R.id.imageButton6);
        ibutton1.setOnClickListener(this);
        ibutton2.setOnClickListener(this);
        ibutton3.setOnClickListener(this);
        ibutton4.setOnClickListener(this);
        ibutton5.setOnClickListener(this);
        ibutton6.setOnClickListener(this);
    }

    public void onClick(View Images) {
        switch (Images.getId()) {

        case R.id.imageButton1:
            i1 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i1, cameraData1);
            break;
        case R.id.imageButton2:
            i2 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i2, cameraData2);
            break;
        case R.id.imageButton3:
            i3 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i3, cameraData3);
            break;
        case R.id.imageButton4:
            i4 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i4, cameraData4);
            break;
        case R.id.imageButton5:
            i5 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i5, cameraData5);
            break;
        case R.id.imageButton6:
            i6 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i6, cameraData6);
            break;
        }

    }

    private OnClickListener mNextListener = new OnClickListener() {
        public void onClick(View v) {

            EditText edit = (EditText) findViewById(R.id.etTitle);
            EditText editP = (EditText) findViewById(R.id.etPrice);
            EditText editD = (EditText) findViewById(R.id.etDescription);
            long currentTime = System.currentTimeMillis();
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(currentTime);
            String showTime=String.format("%1$tI:%1$tM:%1$tS %1$Tp",cal);

            Intent intent = new Intent(Post.this, PostSet.class);
            intent.putExtra("com.mandam.isellibuy.TITLE", edit.getText().toString());
            intent.putExtra("com.mandam.isellibuy.PRICE", editP.getText().toString());
            intent.putExtra("com.mandam.isellibuy.DESC", editD.getText().toString());
            intent.putExtra("currentTime", currentTime);
            startActivity(intent);

        }
    };
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode ==  RESULT_OK){
            Bundle extras = data.getExtras();
            bmp = (Bitmap) extras.get("data");
            ibutton1.setImageBitmap(bmp);
        }
    }
}
</code></pre>

<p>Here is my layout for that activity:</p>

<pre><code>&lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" &gt;

    &lt;LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/carbon_pattern"
        android:orientation="vertical" &gt;

        &lt;TextView
            android:id="@+id/tvPostCategories"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/category"
            android:textSize="15dp" /&gt;

        &lt;Spinner
            android:id="@+id/spCategoryPost"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp" /&gt;

        &lt;TextView
            android:id="@+id/tvTitle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/title"
            android:textSize="15dp" /&gt;

        &lt;EditText
            android:id="@+id/etTitle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:hint="@string/title_hint" &gt;
        &lt;/EditText&gt;

        &lt;LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" &gt;

            &lt;TextView
                android:id="@+id/tvPrice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:text="@string/price"
                android:textSize="15dp" /&gt;

            &lt;EditText
                android:id="@+id/etPrice"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginRight="15dp"
                android:layout_weight="1"
                android:hint="@string/price_hint"
                android:inputType="numberDecimal" /&gt;
        &lt;/LinearLayout&gt;
&lt;LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" &gt;

            &lt;CheckBox
                android:id="@+id/rbAll"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/rbAll" /&gt;

            &lt;CheckBox
                android:id="@+id/rbEmail"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/rbuttonEmail" /&gt;
        &lt;/LinearLayout&gt;

        &lt;LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" &gt;

            &lt;CheckBox
                android:id="@+id/rbPhone"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/PhoneCall" /&gt;

            &lt;CheckBox
                android:id="@+id/rbText"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/TextMessage" /&gt;
        &lt;/LinearLayout&gt;
        &lt;TextView
            android:id="@+id/tvPhoneExtra"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:gravity="center"
            android:text="@string/etPhoneExtraHint"
            android:textSize="15dp" /&gt; 
        &lt;TextView
            android:id="@+id/tvEmail"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:gravity="center"
            android:text="@string/email_post"
            android:textSize="15dp" /&gt;

        &lt;EditText
            android:id="@+id/etEmail"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:hint="@string/email_hint"
            android:inputType="textEmailAddress" /&gt;

        &lt;EditText
            android:id="@+id/etEmailConfirm"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:hint="@string/email_hint_confirm"
            android:inputType="textEmailAddress" /&gt;

        &lt;TextView
            android:id="@+id/tvPhone"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:gravity="center"
            android:text="@string/phoneText"
            android:textSize="15dp" /&gt;


        &lt;EditText
            android:id="@+id/etPhone"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:hint="@string/hintPhone"
            android:inputType="phone" /&gt;

        &lt;EditText
            android:id="@+id/etPhoneConfirm"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:hint="@string/reenterPhone"
            android:inputType="phone" /&gt;

        &lt;TextView
            android:id="@+id/tvDescription"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:gravity="center"
            android:text="@string/description"
            android:textSize="15dp" /&gt;

        &lt;EditText
            android:id="@+id/etDescription"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_weight="1"
            android:hint="@string/description_hint"
            android:inputType="textMultiLine" /&gt;





            &lt;ImageButton
                android:id="@+id/imageButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@android:drawable/btn_star" /&gt;

            &lt;ImageButton
                android:id="@+id/imageButton2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@android:drawable/btn_star" /&gt;

            &lt;ImageButton
                android:id="@+id/imageButton3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@android:drawable/btn_star" /&gt;




            &lt;ImageButton
                android:id="@+id/imageButton4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@android:drawable/btn_star" /&gt;

            &lt;ImageButton
                android:id="@+id/imageButton5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@android:drawable/btn_star" /&gt;

            &lt;ImageButton
                android:id="@+id/imageButton6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@android:drawable/btn_star" /&gt;





        &lt;Button
            android:id="@+id/bNext"
            android:layout_width="fill_parent"
            android:layout_height="56dp"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp"
            android:layout_marginTop="10dp"
            android:drawableRight="@drawable/ic_menu_forward"
            android:text="@string/next"
            android:textSize="25dp" /&gt;
    &lt;/LinearLayout&gt;

&lt;/ScrollView&gt;
</code></pre>
