![](/img/trans.png)
[英]Set image and text of list view item in another imageview and textview
[英]Set text for a textview in a custom list view
我的自定義列表視圖中存在問題。 列表視圖的每一行都包含一個按鈕和一個文本視圖,單擊該按鈕時,會將特定的字符串分配給該文本視圖。 首先,它像一種魅力一樣工作,然后出現一個奇怪的問題。
當我單擊特定行的按鈕時,所需的字符串已分配給下一個textview(這是正常的),但我注意到另一行中的另一個textview也已分配了該字符串,因此setext(string)已分配給了兩個只需單擊一下,即可在不同行中顯示textviews。這是我在公共getView中使用的代碼
holder.bu6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
holder.textViewNumber.setText(String.valueOf(counter[position]));
}
});
您可以使用模型獲取器設置器創建列表。
public class Category {
private String category;
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public Category(String category) {
this.category = category;
}
}
now when you click on button then change string of that position in your list and notify your adapter.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.