Home > Mobile >  For help! The listview textview reuse how to solve
For help! The listview textview reuse how to solve

Time:10-05

Click the add button, the first item in the textview + 1, but after sliding listview, find new item textview also + 1,

CodePudding user response:

List the item of reuse learn not learn? ViewHolder, as long as learned will use it, not just looking for baidu

CodePudding user response:

reference 1/f, no fucker said reply:
list item reuse learn not learn? ViewHolder, as long as studied with, not just looking for baidu

I was self-taught, baidu see didn't solve the problem for several days, and you can tell me the main code,

CodePudding user response:

refer to the second floor N_e_o response:
Quote: reference 1/f, no fucker said reply:
list item reuse learn not learn? ViewHolder, as long as studied with, not just looking for baidu

I was self-taught, baidu see didn't solve the problem for several days, and you can tell me the main code,

The Adapter code to stick out

CodePudding user response:

reference no fucker said reply: 3/f
Quote: refer to the second floor N_e_o response:

Quote: refer to 1st floor without fucker said reply:
list item reuse learn not learn? ViewHolder, as long as studied with, not just looking for baidu

I was self-taught, baidu see didn't solve the problem for several days, and you can tell me the main code,

Adapter code post

I'm sorry, today is a little thing, code:
Public View getView (final int I, View View and ViewGroup ViewGroup) {
Final ViewHolder ViewHolder;
If (the context==null) {
The context=viewGroup. GetContext ();
}
If (view==null) {

View=LayoutInflater. The from (context). Inflate (R.l ayout. Result, null);
ViewHolder=new viewHolder ();
ViewHolder. Picture=(ImageView) view. The findViewById (R.i d.p icture);
ViewHolder. Name=(TextView) view. The findViewById (R.i d.n ame);
ViewHolder. Introduce=(TextView) view. The findViewById (R.i d.i ntroduce);
ViewHolder. Count=(TextView) view. The findViewById (R.i, dc mount);
ViewHolder. Add=(Button) view. The findViewById (da dd R.i);
ViewHolder. Reduce=(Button) view. The findViewById (R.i d.r educe);
The setTag (viewHolder);
}

The else {
ViewHolder=(viewHolder) the getTag ();
}
ViewHolder. Picture. SetImageResource ((Integer) list. Get (I). The get (" picture "));
ViewHolder. Picture. SetTag (R.i d.p icture, I);
ViewHolder. Name. SetText ((CharSequence) list. Get (I). The get (" name "));
ViewHolder. Name. SetTag (R.i d.n ame, I);
ViewHolder. Introduce. SetText ((CharSequence) list. Get (I). The get (" introduce "));
ViewHolder. Introduce. SetTag (R.i d.i ntroduce, I);
ViewHolder. Count. SetTag (R.i, dc mount, I);
ViewHolder. Add. SetTag (da dd, R.i I);
ViewHolder. Add. SetOnClickListener (new an OnClickListener () {
@ Override
Public void onClick (View arg0) {
//TODO Auto - generated method stub
String ss=String. The valueOf (viewHolder. Count. GetText ());
The Integer sum=Integer. The valueOf (ss);
Sum++;
A hashMap. Put (I, sum);
ViewHolder. Count. SetText (Integer. ToString (hashMap. Get (I)));
}
}); ViewHolder. Reduce. SetTag (R.i d.r educe, I);
Return the view;
}

CodePudding user response:

reference no fucker said reply: 3/f
Quote: refer to the second floor N_e_o response:

Quote: refer to 1st floor without fucker said reply:
list item reuse learn not learn? ViewHolder, as long as studied with, not just looking for baidu

I was self-taught, baidu see didn't solve the problem for several days, and you can tell me the main code,

Adapter code post

Suddenly thought of, problem solving, thank you,

CodePudding user response:

In your list add a variable to hold the line, each time the bind take save

New look on the blog: https://blog.csdn.net/weimingjue/article/details/87921494
  • Related