Note that there are some explanatory texts on larger screens.

plurals
  1. POWrong reference in ListView Android?
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/bzsOk.png" alt="enter image description here"> Hi everyone,</p> <p>I have a issue that stuck me 2 day, As you see the image, I start ONLY process #1 and update process to process bar but when I scroll down I see that another "process bar" run, It has the same process status as my first one (#1). I guess that my<code>ListView</code> items are reused and it use my process bar too, Does any one meet that problem? I also attach code as below,</p> <p>Thank for your reading</p> <pre><code> class gridAdapter extends BaseAdapter{ @Override public int getCount() { // TODO Auto-generated method stub return list.size(); } @Override public Object getItem(int position) { // TODO Auto-generated method stub return null; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub String currentText = list.get(position); View cell = convertView; if(cell==null){ LayoutInflater inflater = MainActivity.this.getLayoutInflater(); cell = inflater.inflate(R.layout.gird_tiem, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) cell.findViewById(R.id.tv_test); viewHolder.button = (Button) cell.findViewById(R.id.button); viewHolder.progressBar = (ProgressBar) cell.findViewById(R.id.process); cell.setTag(viewHolder); } final ViewHolder holder = (ViewHolder) cell.getTag(); holder.text.setText(currentText); holder.button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub processManager.onAddItemClick(100, holder.progressBar); } }); return cell; } } static class ViewHolder { public TextView text; public Button button; public ProgressBar progressBar; } </code></pre> <p>//My Process Manager</p> <pre><code>public class ProcessManager { Activity activity; public ProcessManager(Activity activity) { super(); this.activity = activity; } int temp; public void onAddItemClick(final int tasks, final ProgressBar cell) { new Thread(new Runnable() { @Override public void run() { for(int i = 0;i&lt;tasks;i++){ temp = i; Thread thread = new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub } }); thread.run(); try { thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } activity.runOnUiThread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub cell.setProgress((temp*100)/tasks); } }); } } }).start(); } </code></pre> <p>//My item is</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; </code></pre> <p></p> <pre><code>&lt;TextView android:id="@+id/tv_test" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="XXXX" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Start Process" android:id="@+id/button" android:focusable="false" /&gt; &lt;ProgressBar android:id="@+id/process" style="?android:attr/progressBarStyleHorizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:max="100" /&gt; </code></pre> <p> //my Grid view</p> <p></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload