Adding and removing the item into wish list like flipkart
<p>I want to add / remove the item into wishlist. I am getting one response from Api, so in that i have one tag is_wishlist=true/false, when I am launching an application based on that value I am showing its in wishlist by changing an icon, but now issue is if am changing that wishlist status like from adding to remobing to adding, in Api i am getting response sucessfully, but i am unable to change the icons. This is my code. can any one help me how to remove or add items into wishlist</p>

<p><a href="https://i.stack.imgur.com/qXttb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qXttb.png" alt="this is my image when i am launching application"></a></p>

<pre><code>package com.example.user.smgapp;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.squareup.picasso.Picasso;

import java.util.HashMap;
import java.util.List;

public class Prd_grid_adapter extends BaseAdapter {


    List&lt;HashMap&lt;String, String&gt;&gt; Category_listData;
    HashMap&lt;String, String&gt; map;
    Context context;
    Typeface face;
    String wishList_url, remove_wishList_url;
    Cursor cursor;
    NavigationDrawer nav = new NavigationDrawer();

    private static LayoutInflater inflater = null;

    public Prd_grid_adapter(Activity context, List&lt;HashMap&lt;String, String&gt;&gt; aList) {
        // TODO Auto-generated constructor stub
        Category_listData = aList;
        /*/for(int i=1;i&lt;aList.size();i++)
        {
            Category_listData.add(aList.get(i));
        }*/
        this.context = context;
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);


    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return Category_listData.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public class Holder {
        TextView name, price, original_price;
        ImageView img, wish_list;
    }

    @Override
    public View getView(final int position, final View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        final Holder holder = new Holder();
        final View rowView;
        this.face = Typeface.createFromAsset(context.getAssets(), "fonts/OpenSans-Regular.ttf");
        rowView = inflater.inflate(R.layout.grid_item_view, null);
        holder.name = (TextView) rowView.findViewById(R.id.p_name);
        holder.img = (ImageView) rowView.findViewById(R.id.p_img);
        holder.wish_list = (ImageView) rowView.findViewById(R.id.wish_list);
        holder.price = (TextView) rowView.findViewById(R.id.p_price);
        holder.original_price = (TextView) rowView.findViewById(R.id.orginal_p);
        map = Category_listData.get(position);
        holder.name.setTypeface(face);
        holder.name.setText(map.get("product_name"));
        Log.e("wish list staus..", "wishlist status.." + map.get("is_wishlist"));
        if (map.get("is_wishlist").equals("0")) {
            holder.wish_list.setImageResource(R.drawable.empty_wishlist);
        } else {
            holder.wish_list.setImageResource(R.drawable.wishlist);
        }


        holder.wish_list.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (SingletonActivity.custidstr.isEmpty()) {
                    Toast.makeText(context, "Ur not logged in,Please Login", Toast.LENGTH_SHORT).show();

                    AlertDialog.Builder builder = new AlertDialog.Builder(context);
                    builder.setTitle("Alert!");
                    builder.setMessage("Ur not logged in")
                            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {
                                    Intent intent = new Intent(context, Login.class);
                                    context.startActivity(intent);
                                }


                            });
                    // Create the AlertDialog object and return it
                    builder.show();

                } else {
                    wishList_url = SingletonActivity.API_URL + "api/add_wishlist.php?customer_id=" + SingletonActivity.custidstr + "&amp;product_id=" + Category_listData.get(position).get("product_id");
                    remove_wishList_url = SingletonActivity.API_URL + "api/remove_item_wishlist.php?customerid=" + SingletonActivity.custidstr + "&amp;productid=" + Category_listData.get(position).get("product_id");
                    Log.e("wishlist api..", "wish list api.." + wishList_url);
                    Log.e("remove wishlist api..", "remove wish list api.." + remove_wishList_url);
                    v.setActivated(!v.isActivated());
                    String wish_status = map.get("is_wishlist");
                    Log.e("wish status..", "wish status.." + wish_status);
                    int stat = Integer.parseInt(wish_status);
                   // notifyDataSetChanged();

                    /*if (wish_status=="Product already exists in wishlist"){
                        Toast.makeText(context,"removed....",Toast.LENGTH_SHORT).show();
                        nav.removeFromwishList(remove_wishList_url);
                        holder.wish_list.setImageResource(R.drawable.empty_wishlist);

                    }
                    else
                    {
                        nav.addTowishList(wishList_url);
                        Toast.makeText(context,"addedd..",Toast.LENGTH_SHORT).show();
                        holder.wish_list.setImageResource(R.drawable.wishlist);
                    }*/
                    if (stat == 0) {
                        nav.addTowishList(wishList_url);
                        Toast.makeText(context, "addedd..", Toast.LENGTH_SHORT).show();
                        holder.wish_list.setImageResource(R.drawable.wishlist);
                 //       notifyDataSetChanged();
                    /*   ((Activity)context).finish();
                        Intent i=   ((Activity) context).getIntent();
                        context.startActivity(i);*/

                      //

                    } else {
                        nav.removeFromwishList(remove_wishList_url);
                        holder.wish_list.setImageResource(R.drawable.empty_wishlist);
                        Toast.makeText(context, "removed....", Toast.LENGTH_SHORT).show();
                      /* ((Activity)context).finish();
                        Intent i=   ((Activity) context).getIntent();
                        context.startActivity(i);*/
                  //      notifyDataSetChanged();
                    }
                   /* v.setActivated(!v.isActivated());
                    if (v.isActivated()){
                        Toast.makeText(context,"addedd..",Toast.LENGTH_SHORT).show();
                        holder.wish_list.setImageResource(R.drawable.wishlist);
                        nav.addTowishList(wishList_url);
                    }
                    else {
                        Toast.makeText(context,"removed....",Toast.LENGTH_SHORT).show();
                        nav.removeFromwishList(remove_wishList_url);
                        holder.wish_list.setImageResource(R.drawable.empty_wishlist);
                    }*/


                }


            }
        });


        if (map.get("special_price").equals("0.00")) {
            holder.price.setVisibility(View.INVISIBLE);
            // holder.o_price.setVisibility(View.INVISIBLE);
            holder.original_price.setText("Rs." + map.get("product_price"));
            holder.original_price.setTextAppearance(context, R.style.product_price_txt);

        } else {
            holder.price.setText("Rs." + map.get("special_price"));
            holder.original_price.setText("Rs." + map.get("product_price"));
            holder.original_price.setPaintFlags(holder.original_price.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        }
       /* holder.price.setText("Rs." + map.get("special_price"));
        holder.original_price.setText("Rs."+map.get("product_price"));
        holder.original_price.setPaintFlags(holder.original_price.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);*/
        Picasso.with(context).load(map.get("product_image")).placeholder(R.drawable.loading)
                .fit().into(holder.img);
        return rowView;
    }

}
</code></pre>