I have included my ListAdapter in my EMPLOYEE class. And list1 contains the values Empname, Eno, the salary is received from webservices.Now after displaying 5 entries in the employee screen ... when I click "Depatring activity" and return to the employee ... initial 5 entries are added to the list, and now 10 entries are present etc ... the process continues like this ... Please help me so that no duplicates are added, and it should update the list.
Note: clear () or notifydatasetchanged (), invalidate () do not work.
ListAdapter adapter = new SimpleAdapter(this, list1,
R.layout.employee, new String[] { "EmpName","Eno", "Salary" }, new int[]
{R.id.ename, R.id.eno,R.id.sal});
setListAdapter(adapter);
Listview lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
pos = position;
registerForContextMenu(getListView());
}
});
TextView tvdept = (TextView) findViewById(R.id.Department);
tvdept.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(Employee.this, Department.class));
}
});
source
share