ListView with buttons in list item
<p>I have a listview with two buttons (Minus and plus). When I press a button I what that a <code>textview</code> in <code>list item</code> to be modified. The problem is if I press a button and scroll, there will be other textviews randomly modified. 
If I press on the plus image on the first item list, will be affected the first item list and the first item that is visible after I will scroll. And so on
I will post all the code bellow.</p>

<p>DetaliiRestaurantActivity.java:</p>

<pre><code>import android.app.ProgressDialog;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ListView;
import android.widget.TextView;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

public class DetaliiRestaurantActivity extends AppCompatActivity {
public static final int CONNECTION_TIMEOUT=10000;
public static final int READ_TIMEOUT=15000;
public String passedID=null;
public String passedNume=null;
public int nrprodus=1;
public static StringBuilder comanda = new StringBuilder();
ArrayList&lt;SearchResults&gt; results = new ArrayList&lt;SearchResults&gt;();

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

    passedID = getIntent().getExtras().getString("ID");
    passedNume = getIntent().getExtras().getString("Nume");

    TextView Nume = (TextView)findViewById(R.id.textViewTitluRestaurant);
    Nume.setText(passedNume);

    lista();

}
private void lista()
{

    while(tip&lt;10) {
        new AsyncLogin().execute(passedID, String.valueOf(tip));
        tip++;
    }
    final ListView lv = (ListView) findViewById(R.id.products_listview);
    lv.setAdapter(new MyCustomBaseAdapter(this, results));

}
private class AsyncLogin extends AsyncTask&lt;String, String, String&gt;
{
    ProgressDialog pdLoading = new ProgressDialog(DetaliiRestaurantActivity.this);
    HttpURLConnection conn;
    URL url = null;
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        Log.d("DetaliiRestaurant", "12");

        //this method will be running on UI thread
        pdLoading.setMessage("\tLoading...");
        pdLoading.setCancelable(false);
        pdLoading.show();
    }
    @Override
    protected String doInBackground(String... params) {
        try {

            // Enter URL address where your php file resides
            url = new URL("http://192.168.0.105/aplications_scripts/meniu.inc.php");

        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return "exception";
        }
        try {
            // Setup HttpURLConnection class to send and receive data from php and mysql
            conn = (HttpURLConnection)url.openConnection();
            conn.setReadTimeout(READ_TIMEOUT);
            conn.setConnectTimeout(CONNECTION_TIMEOUT);
            conn.setRequestMethod("POST");

            // setDoInput and setDoOutput method depict handling of both send and receive
            conn.setDoInput(true);
            conn.setDoOutput(true);

            // Append parameters to URL
            Uri.Builder builder = new Uri.Builder()
                    .appendQueryParameter("id", params[0])
                    .appendQueryParameter("tip", params[1]);
            String query = builder.build().getEncodedQuery();

            // Open connection for sending data
            OutputStream os = conn.getOutputStream();
            BufferedWriter writer = new BufferedWriter(
                    new OutputStreamWriter(os, "UTF-8"));
            writer.write(query);
            writer.flush();
            writer.close();
            os.close();
            conn.connect();

        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
            return "exception";
        }

        try {

            int response_code = conn.getResponseCode();

            // Check if successful connection made
            if (response_code == HttpURLConnection.HTTP_OK) {

                // Read data sent from server
                InputStream input = conn.getInputStream();
                BufferedReader reader = new BufferedReader(new InputStreamReader(input));
                StringBuilder result = new StringBuilder();
                String line;
                Log.d("DetaliiRestaurant", "13");

                while ((line = reader.readLine()) != null) {
                    result.append(line);
                }

                // Pass data to onPostExecute method
                return(result.toString());

            }else{

                return("unsuccessful");
            }

        } catch (IOException e) {
            e.printStackTrace();
            return "exception";
        } finally {
            conn.disconnect();
        }
    }

    @Override
    protected void onPostExecute(String result) {
        //this method will be running on UI thread

        pdLoading.cancel();

        String[] a = new String[60];
        a = result.split("ENDOFONE");

        String[] tipuri = new String[60];
        if(a[0].equalsIgnoreCase("true")) {

            tipuri = a[1].split("ENDOFORDER");

            int x=tipuri.length;
            int i=0;

            String[] detalii = new String[60];

            while(i&lt;x)
            {
                detalii = tipuri[i].split("END");
                SearchResults sr = new SearchResults();

                sr.setName(detalii[0]);
                sr.setIngrediente(detalii[1]);
                sr.setPret(detalii[2]);
                results.add(sr);
                i++;
            }
        }
    }
}

}
</code></pre>

<p>SearchResults.java:</p>

<pre><code> public class SearchResults {
private String name = "";
private String pret = "";
private String ingrediente = "";
private String cantitate = "";

public void setName(String name) {
    this.name = name;
}

public String getName() {
    return name;
}


public void setPret(String pret) {
    this.pret = pret;
}

public String getPret() {
    return pret;
}


public void setIngrediente(String ingrediente) {
    this.ingrediente = ingrediente;
}

public String getIngrediente() {
    return ingrediente;
}

public void setCantitate(String cantitate) {
    this.cantitate = cantitate;
}

public String getCantitate() {
    return cantitate;
}

}
</code></pre>

<p>MyCustomAdapter.java: </p>

<pre><code>import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;

public class MyCustomBaseAdapter extends BaseAdapter {
private static ArrayList&lt;SearchResults&gt; searchArrayList;
private LayoutInflater mInflater;
protected ListView mListView;

public MyCustomBaseAdapter(Context context, ArrayList&lt;SearchResults&gt; results) {
    searchArrayList = results;
    mInflater = LayoutInflater.from(context);
}

public int getCount() {
    return searchArrayList.size();
}

public Object getItem(int position) {
    return searchArrayList.get(position);
}

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

static class ViewHolder {
    TextView txtNumeProdus;
    TextView txtPret;
    TextView txtIngrediente;
    ImageButton imageButtonMinus;
    ImageButton imageButtonPlus;
}

public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder=null;

    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.list_item, null);
        holder = new ViewHolder();
        holder.txtNumeProdus = (TextView) convertView.findViewById(R.id.NumeProdus);
        holder.txtPret = (TextView) convertView
                .findViewById(R.id.pret);
        holder.txtIngrediente = (TextView) convertView.findViewById(R.id.ingrediente);
        holder.imageButtonMinus = (ImageButton) convertView.findViewById(R.id.cart_minus_img);
        holder.imageButtonPlus = (ImageButton) convertView.findViewById(R.id.cart_plus_img);

        final View finalview = convertView;

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

                Log.d("DetaliiRestaurant", "minus");
                Log.d("poz", String.valueOf(position));
                final TextView textview = (TextView) finalview.findViewById(R.id.cart_product_quantity_tv);
                int x= Integer.parseInt(textview.getText().toString());
                Log.d("DetaliiRestaurant", String.valueOf(x));
                if(x&gt;0) {
                    x = x - 1;
                    textview.setText(String.valueOf(x));
                }

            }
        });
        holder.imageButtonPlus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d("DetaliiRestaurant", "plus");
                Log.d("poz", String.valueOf(position));
                final TextView textview = (TextView) finalview.findViewById(R.id.cart_product_quantity_tv);
                int x= Integer.parseInt(textview.getText().toString());
                Log.d("DetaliiRestaurant", String.valueOf(x));
                x=x+1;
                textview.setText(String.valueOf(x));
            }
        });

        convertView.setTag(holder);
        finalview.setTag(holder);
        convertView.setTag(R.id.cart_minus_img, holder.imageButtonMinus);
        convertView.setTag(R.id.cart_plus_img, holder.imageButtonPlus);


    } else {
        holder = (ViewHolder) convertView.getTag();

    }

    holder.imageButtonMinus.setTag(position); // This line is important.
    holder.imageButtonPlus.setTag(position);

    holder.txtNumeProdus.setText(searchArrayList.get(position).getName());
    holder.txtPret.setText(searchArrayList.get(position)
            .getPret());
    holder.txtIngrediente.setText(searchArrayList.get(position).getIngrediente());

    return convertView;
}
}
</code></pre>

<p>I know... it is a lot of cod..My app has been stuck here for 3 days. I search a lot but i didn't find any solution.</p>

<p>This is how its looks:
<img src="https://i.stack.imgur.com/DxBFm.jpg" alt=""></p>