My code as follows:
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
String xml = ParseXMLMethods.getXML();
Document doc = ParseXMLMethods.XMLfromString(xml);
NodeList children = doc.getElementsByTagName(KEY_ITEM);
for (int i = 0; i < children.getLength(); i++)
{
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element)children.item(i);
map.put("PID", ParseXMLMethods.getValue(e, KEY_ID));
map.put("Passionname", ParseXMLMethods.getValue(e, KEY_TITLE));
map.put("Progress", ParseXMLMethods.getValue(e,KEY_PROGRESS));
Log.d("Progress",ParseXMLMethods.getValue(e,KEY_PROGRESS));
map.put("Duedate", ParseXMLMethods.getValue(e, KEY_DUEDATE));
map.put("Action", ParseXMLMethods.getValue(e, KEY_ACTION));
mylist.add(map);
}
adapter = new SimpleAdapter(getBaseContext(), mylist , R.layout.row,
new String[] { KEY_TITLE,KEY_PROGRESS,KEY_DUEDATE,KEY_ACTION},
new int[] {R.id.txt,R.id.progress, R.id.FROM_CELL, R.id.del_btn})
{
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
return itemView;
}
};
adapter.setViewBinder(new MyBinder());
list.setAdapter(adapter);
list.setItemsCanFocus(true);
My ViewBinder class as follows:
class MyBinder implements ViewBinder{
@Override
public boolean setViewValue(View view, Object data, String textRepresentation) {
if(view.getId() == R.id.progress){
String stringval = (String) data;
int progressValue = Integer.parseInt(stringval);
ProgressBar progressbar = (ProgressBar) view;
progressbar.setProgress(progressValue);
Resources res = getResources();
Rect bounds = progressbar.getProgressDrawable().getBounds();
if(progressValue==100)
{
progressbar.setProgressDrawable(res.getDrawable(R.drawable.red_progressbar));
}
else
{
progressbar.setProgressDrawable(res.getDrawable(R.drawable.green_progreesbar));
}
progressbar.getProgressDrawable().setBounds(bounds);
return true;
}
return false;
}
}
whenever run above code got the below errors:
12-01 04:55:37.162: E/AndroidRuntime(3478): java.lang.NumberFormatException: Invalid int: "50 " 12-01 04:55:37.162: E/AndroidRuntime(3478): at java.lang.Integer.invalidInt(Integer.java:137) 12-01 04:55:37.162: E/AndroidRuntime(3478): at java.lang.Integer.parse(Integer.java:374)
but this code run successfully while using a static array for my Progress bar.Please help me...
Here problem is in the data of XML file given below Invalid int: "50 ".Here a space exists after 50 in my xml file,That's why I am getting error.I wasted 3 hr for this issue.