我试图在列表视图中设置textview的位置,并更改从单击listview的按钮位置获得的值。是否有解决方案来设置textview的位置,以便我可以通过单击按钮来更改同一位置上的textview的值?
这是我得到按钮位置时的代码:
viewHolder.increase.setTag(pos);
viewHolder.decrease.setTag(pos);
viewHolder.count.setTag(pos);
viewHolder.increase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int posisi =(Integer)v.getTag();
Log.d(TAG, "POSISI TAMBAH : " + posisi);
countcheckBox++;
changeCheckBox(posisi);
produk.hitung();
}
});
viewHolder.decrease.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int posisi =(Integer)v.getTag();
Log.d(TAG, "POSISI KURANG : " + posisi);
if (countcheckBox>0) {
countcheckBox--;
changeCheckBox(posisi);
produk.hitung();
}
}
});
这是更改值的方法:
public void changeCheckBox(int posisix){
Log.d(TAG, "POSISI VALUE : " + posisix);
viewHolder.count.setSelected(posisix); //here i'm trying to set the position of textview that have the same position with the button
viewHolder.count.setText(countcheckBox+"");
}