I have one activity in which I am having one TabHost with two tabs. Both the tabs have one listview each. The activity has one button which start an aync job to get data from internet and then the data is divided into two array adapters one for each listview. Here comes the problem, both the listview are showing the data from the second adapter.
ArrayList<TestClass> detailsToCollect = new ArrayList<TestClass>();
ArrayList<TestClass> detailsToGive = new ArrayList<TestClass>();
for (TestClass TestClass : details) {
if(TestClass.getAmount()>0)
{
detailsToCollect.add(TestClass);
}
else
{
TestClass.setAmount(TestClass.getAmount()*-1);
detailsToGive.add(TestClass);
}
}
if(Double.parseDouble(amount)!=0)
{
imgView1.setVisibility(View.VISIBLE);
downloadFile(GetGraphURL(a, al),imgView1);
lstView1.setVisibility(View.VISIBLE);
lstView1.setAdapter(new CustomAdapter(Home.this,R.layout.detailsrow, detailsToCollect));
}
else
{
nodataCollect.setVisibility(View.VISIBLE);
}
if(Double.parseDouble(amountc)!=0)
{
imgView2.setVisibility(View.VISIBLE);
downloadFile(GetGraphURL(ac, alc),imgView2);
lstView2.setVisibility(View.VISIBLE);
lstView2.setAdapter(new CustomAdapter(Home.this,R.layout.detailsrow, detailsToGive));
}
else
{
nodataGive.setVisibility(View.VISIBLE);
}
Can anybody tell me what is the problem here?
Thanks,
Ashwani
I have fixed the issue by handling setOnTabChangedListener for the tabhost. In this listener I am binding the listviews again to their corresponding adapters.