i cudn exactly understand ur prob ,U jus add items to array list tht u r using fir adapter properly..its getcount 'll take care of items display.. also wen ever u remove an item from list it;ll atomatically updated.. use arraylist...length in get count..reload the list.. i suppose am convincing u..
On Mar 22, 10:19 am, kavitha <kavith...@gmail.com> wrote: > Even I have same problem > > Cant clear all list view items,,when i add new items,,it will add to old > ones > > Can anybody help please > > On Sat, Mar 20, 2010 at 7:32 PM, Tatyana Ulyanova <levkat...@gmail.com>wrote: > > > > > Hello, Kumar! > > > I have a problem when I try to add items to my custom adapter. > > Everytime when i add new item to adapter > > > for(int i=0;i<m_orders.size();i++) > > m_adapter.add(m_orders.get(i)); > > > the size of m_orders (ArrayList joined to ListAdapter) also increase > > and application hangs. > > > For example, i add to m_oders 20 items i need to display, than i must > > add this items to adapter. Everytime when I add new item to adapter, > > size of m_orders becomes 21, 22, 23, ... I don't understand why. > > > If i don't add items to adapter, i have empty listview. > > > I hope i explain my problem :) > > > Much appreciate for your time, Kumar :))) > > > On 19 Бер, 20:06, Kumar Bibek <coomar....@gmail.com> wrote: > > > What errors or problem do you get? > > > > Thanks and Regards, > > > Kumar Bibek > > > > On Mar 19, 8:07 pm, Tatyana Ulyanova <levkat...@gmail.com> wrote: > > > > > Hello, friends! > > > > > I have a problem with adding new items to ListView. > > > > > I use custom adapter MyListAdapter. I do that way: > > > > > public class MyView extends ListActivity{ > > > > > private ArrayList<Order> m_orders = null; > > > > privateMyListAdapter m_adapter; > > > > private Runnable viewOrders; > > > > > @Override > > > > public void onCreate(Bundle savedInstanceState) { > > > > super.onCreate(savedInstanceState); > > > > setContentView(R.layout.main); > > > > m_orders = new ArrayList<Order>(); > > > > this.m_adapter = new OrderAdapter(this, R.layout.row, > > > > m_orders); > > > > setListAdapter(this.m_adapter); > > > > > viewOrders = new Runnable(){ > > > > @Override > > > > public void run() { > > > > getOrders(); > > > > } > > > > }; > > > > Thread thread = new Thread(null, viewOrders, > > > > "MagentoBackground"); > > > > thread.start(); > > > > m_ProgressDialog = ProgressDialog.show(MyView.this, > > > > "Please wait...", "Retrieving data ...", true); > > > > } > > > > private Runnable returnRes = new Runnable() { > > > > > @Override > > > > public void run() { > > > > if(m_orders != null && m_orders.size() > 0){ > > > > m_adapter.notifyDataSetChanged(); > > > > for(int i=0;i<m_orders.size();i++) > > > > m_adapter.add(m_orders.get(i)); > > > > } > > > > m_adapter.notifyDataSetChanged(); > > > > } > > > > }; > > > > > private void getOrders(){ > > > > try{ > > > > m_orders.addAll(/*some order collection*/) > > > > runOnUiThread(returnRes); > > > > } > > > > > private class OrderAdapter extends ArrayAdapter<Order> { > > > > //code about how to get view > > > > > } > > > > } > > > > > But when I add items to my adapter: > > > > for(int i=0;i<m_orders.size();i++) > > > > m_adapter.add(m_orders.get(i)); > > > > the application hangs because of m_orders increase there size, > > > > everytime where new item adds to adapter. > > > > > Friends, do you have any ideas how to implement dynamically adding > > > > items to custom ListAdapter? Do you see any errors in my code? > > > > > Thank you very much :))) > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to android-developers@googlegroups.com > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > > To unsubscribe from this group, send email to android-developers+ > > unsubscribegooglegroups.com or reply to this email with the words "REMOVE > > ME" as the subject. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.