获取通知添加新项目Listview

时间:2017-01-07 06:20:31

标签: android listview baseadapter

我们如何才能看到新元素被添加到电源适配器ListView中?

是新的elemnet获取通知toast消息

                clientslist=new ArrayList<Client>();

                ClientsAdapter adapterCL=new ClientsAdapter(getApplicationContext(), clientslist);
                adapterCL.notifyDataSetChanged();
                lvMain.setAdapter(adapterCL);

请帮助我亲爱的Stackoverfloww

1 个答案:

答案 0 :(得分:0)

for(int i=0; i<response.length();i++)
                {
                    Client client=new Client();
                    try {
                        JSONObject obj=response.getJSONObject(i);
                        client.setId(obj.getInt("id"));
                        client.setAdress(obj.getString("adress_client"));
                        client.setStatus(obj.getInt("status"));
                        client.setTell(obj.getString("phone_num"));
                        client.setNomeratsiya(String.valueOf(jay)+": ");
                        jay++;
                        clientslist.add(client);

                    } catch (JSONException e) {
                        try {
                            JSONObject js=new JSONObject(response.toString());
                            Log.d("js", js.getString("status"));
                        } catch (JSONException e1) {
                            e1.printStackTrace();
                        }
                    }

                }
                ClientsAdapter adapterCL=new ClientsAdapter(getApplicationContext(), clientslist);
                adapterCL.notifyDataSetChanged();
                lvMain.setAdapter(adapterCL);