獲取視圖位置在我的應用程序的應用程序我有一個解析JSON更新500行是列表視圖的API。我連續有id,姓名,號碼和狀態。通過pushnotification獲取id中的500個,我想更新該行的id的狀態。安卓:由<key,value>對
正在使用getter/setter這裏的方法,所以如果獲取視圖的位置,我可以更新該行。
這是我的方式解析
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject c = jsonArray.getJSONObject(i);
String phone = c.getString("phone");
String subDistributorStatus = c.getString("status");
String name = c.getString("firstName");
subDistributerId = c.getString("subDistributerId");
SubdistributorItem item = new SubdistributorItem();
item.setSubDistributorName(name);
item.setSubDistributorNumber(phone);
item.setSubDistributorStatus(subDistributorStatus);
item.setSubDistributorId(subDistributerId);
}
這是正路正在更新單列
SubdistributorItem subdistributorItem = subdistributorItemList.get(Integer.parseInt(getFromPreference("Sub_position")));
String phone= subdistributorItem.getSubDistributorNumber();
String id= subdistributorItem.getSubDistributorId();
String status= subdistributorItem.getSubDistributorStat
我在這裏通過單擊視圖得到的位置。 現在,如果我在行中獲得ID之一,那麼有機會在視圖中獲取位置。
我試過HashMap。
** HashMap newmap = new HashMap(); // in global
newmap.put(subDistributerId,i); //在循環中
Log.e(「Tag」,「hash map positon」+ newmap.get(43)); // onResume **
但失敗。
可以在任何請幫助得到的行的位置,如果得到該行的ID。
我想這裏是你在找什麼,http://stackoverflow.com/a/18016073/2509009 – asadnwfp
我怎麼能得到在arrayList中的位置,如果我給了一個ID @asadnwfp –