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