Đây là mã của tôilistview không cập nhật với notifydatasetchanged() gọi
listview =(ListView) findViewById(R.id.lv1);
ArrayList<SClass> Monday = new ArrayList<SClass>();
SClass s1=new SClass();
s1.sName="samp";
s1.salary=1000;
Monday.add(s1);
temp=Monday;
adapter = new CustomAdap(this, temp);
listview.setAdapter(adapter);
Đoạn mã trên làm việc fine.But khi tôi thay đổi mã của tôi để
listview =(ListView) findViewById(R.id.lv1);
adapter = new CustomAdap(this, temp);
SClass s1=new SClass();
s1.sName="samp";
s1.salary=1000;
Monday.add(s1);
temp=Monday;
listview.setAdapter(adapter);
adapter.notifyDataSetChanged();
listview này không hiển thị anything.what là vấn đề?
này sẽ rõ ràng hơn nếu bạn cung cấp nguồn cho CustomAdap và Thứ Hai, cũng như nơi thứ hai được khai báo. – louielouie
tôi đã thêm mã cho customadap và thứ hai là một Arraylist của SClass –
@TariqIbrahim bạn có thể xem http://stackoverflow.com/questions/28148618/listview-not-refreshing-after-click-on-button –