My issue is regarding listview multiple buttons click. e.g. my list view contain 3 rows and each row contains 3 buttons. when i click on first button in first row it changes color in last row first button

[please check image you will know the problem](http://i.stack.imgur.com/oHaAp.png)

I have tried to solve it using button tags, view holder, tried to assign position to button but still nothing happened 

```
public class ViewOrderAdapter extends BaseAdapter {

    @SuppressWarnings("unused")
    private LayoutInflater mInflater;
    Context mcontext;
    ArrayList<ViewOrder> view_order_array = null;
    SimpleDateFormat sdf;
    String currentTime;
    String ord_id;
    public Button accept_btn, pickup_btn, delieverd_btn, order_view, rest_address, cust_address;
    GPSTracker gps;
    String latitude, longitude;
    private static int ipos;
    boolean[] buttonState;
    AlertDialog alert;
    View view;
    OrdersFragment ord_frag;
    ViewOrderAdapter view_order_adapter1;

    public static final String PREFS_NAME = "MyApp_Settings";
    SharedPreferences settings;
    SharedPreferences.Editor editor;

    SharedPreferences prefs;

    public ViewOrderAdapter (Context context, ArrayList<ViewOrder> view_order_array) {
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.mcontext = context;
        prefs = mcontext.getSharedPreferences(PREFS_NAME, mcontext.MODE_PRIVATE);
        this.view_order_array = view_order_array;
        buttonState = new boolean[view_order_array.size()];
        gps = new GPSTracker(mcontext);
    }

    @Override
    public int getCount() {
        return view_order_array.size();
    }

    @Override
    public Object getItem(int position) {
        return view_order_array.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @SuppressLint("ViewHolder")
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) mcontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.order_single_row, parent, false);
        view = convertView;

        sdf = new SimpleDateFormat("HH:mm:ss");
        currentTime = sdf.format(new Date());

        final ViewOrder v_ordr = view_order_array.get(position);
        TextView cname = (TextView)convertView.findViewById(R.id.restaurant_name_view);
        cname.setText(v_ordr.getRestaurant());
        TextView caddr = (TextView)convertView.findViewById(R.id.restaurant_address_view);
        caddr.setText(v_ordr.getRaddress());

        accept_btn = (Button)convertView.findViewById(R.id.order_accept_btn);
        pickup_btn = (Button)convertView.findViewById(R.id.order_pickup_btn);
        delieverd_btn = (Button)convertView.findViewById(R.id.order_delievery_btn);

        accept_btn.setTag(position);
        pickup_btn.setTag(position);
        delieverd_btn.setTag(position);

        order_view = (Button)convertView.findViewById(R.id.order_info);
        rest_address = (Button)convertView.findViewById(R.id.rest_addrs);
        cust_address = (Button)convertView.findViewById(R.id.cstom_addrs);
        int id = Integer.parseInt(view_order_array.get(position).getId());

        accept_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(final View v) {

                AppConstants.btn_id = view_order_array.get(position).getId();
                String id = AppConstants.btn_id;
                //accept_btn.setId(position);

                buttonState[position] = false;

                String token = AppPreferences.getSharedPrefValue(mcontext, AppConstants.auth);
                ShowMessagesDialogsUtitly.showProgressDialog(mcontext);
                RequestParams requestParams = new RequestParams();
                requestParams.put("k", token);
                requestParams.put("id", id);   //order id
                requestParams.put("status", Integer.toString(1));
                requestParams.put("time", currentTime);
                requestParams.put("page", "send");

                HttpUtils.httpPostRequest(AppConstants.BASE_URL, requestParams, new HttpResponseCallback() {
                    @Override
                    public void onCompleteHttpResponse(String whichUrl, String jsonResponse) {
                        ShowMessagesDialogsUtitly.hideProgressDialog();

                        if (jsonResponse != null) {
                            try {
                                JSONObject jsonResponseObj = new JSONObject(jsonResponse);
                                if (jsonResponseObj.getInt("status") == 1) {
                                    accept_btn.setBackgroundColor(Color.GRAY);

                                    Intent n = new Intent(mcontext, Order.class);
                                    mcontext.startActivity(n);
                                    ((Activity)mcontext).finish();

                                } else {
                                    Toast.makeText(mcontext, "Order progress error", Toast.LENGTH_SHORT).show();
                                }
                            } catch (Exception e) {
                                AppUtilites.printStackTrace(e);
                            }
                        } else {
                            Toast.makeText(mcontext, AppConstants.SERVER_ERROR, Toast.LENGTH_SHORT).show();
                        }
                    }
                });
            }
        });

        pickup_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

                AppConstants.btn_id = view_order_array.get(position).getId();
                String id = AppConstants.btn_id;
                String token = AppPreferences.getSharedPrefValue(mcontext, AppConstants.auth);
                pickup_btn.setId(position);

                ShowMessagesDialogsUtitly.showProgressDialog(mcontext);
                RequestParams requestParams = new RequestParams();
                requestParams.put("k", token);
                requestParams.put("id", id);   //order id
                requestParams.put("status", Integer.toString(2));
                requestParams.put("time", currentTime);
                requestParams.put("page", "send");

                HttpUtils.httpPostRequest(AppConstants.BASE_URL, requestParams, new HttpResponseCallback() {
                    @Override
                    public void onCompleteHttpResponse(String whichUrl, String jsonResponse) {
                        ShowMessagesDialogsUtitly.hideProgressDialog();

                        if (jsonResponse != null) {
                            try {
                                JSONObject jsonResponseObj = new JSONObject(jsonResponse);

                                Toast.makeText(mcontext, "Order accepted", Toast.LENGTH_SHORT).show();
                                } else {
                                    Toast.makeText(mcontext, "Order order not accepted", Toast.LENGTH_SHORT).show();
                                }
                            } catch (Exception e) {
                                AppUtilites.printStackTrace(e);
                            }
                        } else {
                            Toast.makeText(mcontext, AppConstants.SERVER_ERROR, Toast.LENGTH_SHORT).show();
                        }
                    }
                });
            }
        });
        delieverd_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                AppConstants.btn_id = view_order_array.get(position).getId();
                String id = AppConstants.btn_id;
                String token = AppPreferences.getSharedPrefValue(mcontext, AppConstants.auth);
                delieverd_btn.setId(position);

                ShowMessagesDialogsUtitly.showProgressDialog(mcontext);
                RequestParams requestParams = new RequestParams();
                requestParams.put("k", token);
                requestParams.put("id", id);   //order id
                requestParams.put("status", Integer.toString(3));
                requestParams.put("time", currentTime);
                requestParams.put("page", "send");

                HttpUtils.httpPostRequest(AppConstants.BASE_URL, requestParams, new HttpResponseCallback() {
                    @Override
                    public void onCompleteHttpResponse(String whichUrl, String jsonResponse) {
                        ShowMessagesDialogsUtitly.hideProgressDialog();

                        if (jsonResponse != null) {
                            try {
                                JSONObject jsonResponseObj = new JSONObject(jsonResponse);

                                if (jsonResponseObj.getInt("status") == 1) {                        
                                } else {
                                    Toast.makeText(mcontext, "Order order not delievered", Toast.LENGTH_SHORT).show();
                                }
                            } catch (Exception e) {
                                AppUtilites.printStackTrace(e);
                            }
                        } else {
                            Toast.makeText(mcontext, AppConstants.SERVER_ERROR, Toast.LENGTH_SHORT).show();
                        }
                    }
                });
            }
        });

        order_view.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                LayoutInflater inflater = (LayoutInflater) mcontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View layout = inflater.inflate(R.layout.order_view_lay, (ViewGroup)view.findViewById(R.id.order_view_lay_id));
                AlertDialog.Builder builder = new AlertDialog.Builder(mcontext);
                builder.setView(layout);
                alert = builder.create();

                TextView order_id = (TextView) layout.findViewById(R.id.order_no);
                order_id.setText(view_order_array.get(position).getOid());
                TextView rest_name = (TextView) layout.findViewById(R.id.rstarnt_name);
                rest_name.setText(view_order_array.get(position).getRestaurant());

                TextView quantity = (TextView) layout.findViewById(R.id.quantity);
                quantity.setText(view_order_array.get(position).getOid());
                TextView item = (TextView) layout.findViewById(R.id.item);
                item.setText(view_order_array.get(position).getMenu());
                TextView price = (TextView) layout.findViewById(R.id.price);
                price.setText(view_order_array.get(position).getAmount());

                TextView subtotal = (TextView) layout.findViewById(R.id.sub_total);
                subtotal.setText("XXXX");
                TextView total = (TextView) layout.findViewById(R.id.total);
                total.setText("XXXX");

                Button ok = (Button) layout.findViewById(R.id.ok_popup_order_view_btn);
                ok.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        alert.dismiss();
                    }
                });
                alert.show();
            }
        });
        rest_address.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                LayoutInflater inflater = (LayoutInflater) mcontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View layout = inflater.inflate(R.layout.restaurant_addr_lay, (ViewGroup)view.findViewById(R.id.rest_addr_lay_id));
                AlertDialog.Builder builder = new AlertDialog.Builder(mcontext);
                builder.setView(layout);
                alert = builder.create();

                TextView r_name = (TextView) layout.findViewById(R.id.rst_name_popup);
                r_name.setText(view_order_array.get(position).getRestaurant());
                TextView r_add = (TextView) layout.findViewById(R.id.rst_addr_popup);
                r_add.setText(view_order_array.get(position).getRaddress());
                TextView r_phone = (TextView) layout.findViewById(R.id.rst_phone_popup);
                r_phone.setText(view_order_array.get(position).getRestaurant());

                Button map = (Button) layout.findViewById(R.id.map_to_restaurant_popup);
                map.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        if (gps.canGetLocation()) {
                            latitude = gps.getLatitude() + "";
                            longitude = gps.getLongitude() + "";

                            AppConstants.Latitude = latitude.toString();
                            AppConstants.Longitude = longitude.toString();

                            double lat = Double.valueOf(latitude);
                            double lon = Double.valueOf(longitude);
                            gps.getCompleteAddressString(lat, lon);

                            AppConstants.Address_To = view_order_array.get(position).getRaddress();
                            String addr = AppConstants.Address_To;
                            gps.getLocationFromAddress(mcontext, addr);
                            Intent intent = new Intent(mcontext, MapLayout.class);
                            mcontext.startActivity(intent);
                        } else {
                            gps.showSettingsAlert();
                        }
                    }
                });

                Button map_dirct = (Button) layout.findViewById(R.id.directions_to_restaurant_popup);
                map_dirct.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        if (gps.canGetLocation()) {
                            latitude = gps.getLatitude() + "";
                            longitude = gps.getLongitude() + "";

                            AppConstants.Latitude = latitude.toString();
                            AppConstants.Longitude = longitude.toString();

                            double lat = Double.valueOf(latitude);
                            double lon = Double.valueOf(longitude);
                            gps.getCompleteAddressString(lat, lon);

                            AppConstants.Address_To = view_order_array.get(position).getRaddress();
                            Intent intent = new Intent(mcontext, MapLayout.class);
                            mcontext.startActivity(intent);
                        } else {
                            gps.showSettingsAlert();
                        }
                    }
                });

                Button ok = (Button) layout.findViewById(R.id.ok_popup_raddr_btn);
                ok.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        alert.dismiss();
                    }
                });
                alert.show();
            }
        });
        cust_address.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                LayoutInflater inflater = (LayoutInflater) mcontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View layout = inflater.inflate(R.layout.customer_addr_lay, (ViewGroup)view.findViewById(R.id.cust_addr_lay_id));
                AlertDialog.Builder builder = new AlertDialog.Builder(mcontext);
                builder.setView(layout);
                alert = builder.create();

                TextView c_name = (TextView) layout.findViewById(R.id.cst_name_popup);
                c_name.setText(view_order_array.get(position).getCustomer());
                TextView c_add = (TextView) layout.findViewById(R.id.cst_addr_popup);
                c_add.setText(view_order_array.get(position).getCaddress());
                TextView c_phone = (TextView) layout.findViewById(R.id.cst_phone_popup);
                c_phone.setText(view_order_array.get(position).getCphone());
                TextView order_inst = (TextView) layout.findViewById(R.id.cst_order_inst_popup);
                order_inst.setText(view_order_array.get(position).getInstruction());

                Button map = (Button) layout.findViewById(R.id.map_to_customer_popup);
                map.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        if (gps.canGetLocation()) {
                            latitude = gps.getLatitude() + "";
                            longitude = gps.getLongitude() + "";

                            AppConstants.Latitude = latitude.toString();
                            AppConstants.Longitude = longitude.toString();

                            double lat = Double.valueOf(latitude);
                            double lon = Double.valueOf(longitude);
                            gps.getCompleteAddressString(lat, lon);

                            AppConstants.Address_To = view_order_array.get(position).getCaddress();
                            Intent intent = new Intent(mcontext, MapLayout.class);
                            mcontext.startActivity(intent);
                        } else {
                            gps.showSettingsAlert();
                        }
                    }
                });

                Button map_direct = (Button) layout.findViewById(R.id.directions_to_customer_popup);
                map_direct.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        if (gps.canGetLocation()) {
                            latitude = gps.getLatitude() + "";
                            longitude = gps.getLongitude() + "";

                            AppConstants.Latitude = latitude.toString();
                            AppConstants.Longitude = longitude.toString();

                            double lat = Double.valueOf(latitude);
                            double lon = Double.valueOf(longitude);
                            gps.getCompleteAddressString(lat, lon);

                            AppConstants.Address_To = view_order_array.get(position).getCaddress();
                            Intent intent = new Intent(mcontext, MapLayout.class);
                            mcontext.startActivity(intent);
                        } else {
                            gps.showSettingsAlert();
                        }
                    }
                });

                Button ok = (Button) layout.findViewById(R.id.ok_popup_caddr_btn);
                ok.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        alert.dismiss();
                    }
                });
                alert.show();
            }
        });
        return convertView;
    }
}

```