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
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.

Reply via email to