4
我在實時更新TextView
時遇到問題。我想用一個自定義適配器實時更新ListView
的TextView
。我有我的套接字I/O處理程序,我收到一條JSON消息。我想分析這個JSON並將該文本放入setText()
的特定列表行中。我如何獲得ListView
行的索引並更新其TextView
?實時更新ListView中的TextView
responseid=object.getString("ResponseID");
if(responseid!=null){
for(int j=0;j<countryList.size();j++){
//If the countryList row match then i want to update the textView of that particular row
if(countryList.get(j).getName().equals(caseid)) {
int oldcount = Integer.parseInt((dataAdapter.findViewById(R.id.replycount)).getText().toString());
int total=oldcount+1;
(dataAdapter.findViewById(R.id.replycount)).setText(Integer.toString(total));
dataAdapter.notifyDataSetChanged();
}
}
}
//Here is my solution
for(int j=0;j<countryList.size();j++)
{
if(countryList.get(j).getName().equals(caseid))
{
String oldcount = countryList.get(j).getCount();
int oldcountint = Integer.parseInt(oldcount);
int newcount = oldcountint + 1;
countryList.get(j).setCount(Integer.toString(newcount));
dataAdapter.notifyDataSetChanged();
break;
}
}
讓我試試這一個 – Nik 2013-02-28 21:19:37
@Neik Haarman謝謝 – 2014-10-01 12:21:28