Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to maintain array list for new added element?
    primarykey
    data
    text
    <p>Hello every one i am working on app which is similar to the facebook.In that currently i am stuck in one point like we have posts in facebook which shows on our wall in that all the post is shows in bulk like 20 20 fashion that same thing i want to apply in my app. For that thing i use listview which get value form server and create view according to that i also get all value but the problem is that when i add 1st 20 value then it work fine but when i add another 20 value it will delete the previous data in listview.</p> <p>any idea how i can do this thing in my app and thanks in advance.... </p> <p>my function get value from the server</p> <pre><code>private void getPostnew(String start) { String URL = start; System.out.println("start value new :" + start); final String usernamefor = ""; aq = new AQuery(getParent()); listitem = new ArrayList&lt;BeanTop&gt;(); aq.ajax(URL, JSONObject.class, 10 * 1000, new AjaxCallback&lt;JSONObject&gt;() { @Override public void callback(String url, JSONObject json1, AjaxStatus status) { System.out.println("json " + json1); if (json1 == null) { } else { try { JSONArray jarray = json1 .getJSONArray("subject"); for (int j = 0; j &lt; jarray.length(); j++) { try { JSONObject j1 = jarray.getJSONObject(j); try { listcount = j1 .getString("likecount"); } catch (Exception e) { listcount = "0"; } AddObject(j1.getString("text"), j1.getString("leftpic"), j1.getString("rightpic"), j1.getString("rightvotecount"), j1.getString("leftvotecount"), j1.getString("textleft"), j1.getString("textright"), j1.getString("date_created"), j1.getString("voteid"), j1.getString("user"), j1.getString("dom"), j1.getString("Isvoted"), j1.getString("Islike"), j1.getString("profilepic"), listcount, j1.getString("commentcount")); } catch (Exception e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } FriendlistAdapter ad = new FriendlistAdapter(Top.this, listitem); subjectlist.setAdapter(ad); ad.notifyDataSetChanged(); } }); } </code></pre> <p>method for save the data in bean class </p> <pre><code>private void AddObject(String string1, String string2, String string3, String string5, String string6, String string7, String string8, String string9, String string10, String string11, String usernamefor, String isvoted, String isliked, String profilepic, String likecount, String commentcount) { BeanTop ib = new BeanTop(); Date date = null; try { System.out.println("date " + string9); date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(string9); } catch (Exception e) { e.printStackTrace(); } ib.setText(string1); ib.setLeftpic(string2); ib.setRightpic(string3); ib.setRightVote(string5); ib.setLeftVote(string6); ib.setLefttext(string7); ib.setRighttext(string8); ib.setDate(string9); ib.setDate1(date); ib.setVoteid(string10); ib.setUsername(string11); ib.setDom(usernamefor); ib.setIsvoted(isvoted); ib.setIsliked(isliked); ib.setProfilepic(profilepic); ib.setLikecount(likecount); ib.setCommentcount(commentcount); List&lt;BeanTop&gt; bookingList = new ArrayList&lt;BeanTop&gt;(); bookingList.addAll(listitem); Collections.sort(bookingList, new Comparator&lt;BeanTop&gt;() { public int compare(BeanTop m1, BeanTop m2) { return m1.getDate().compareTo(m2.getDate()); } }); Collections.reverse(bookingList); try { listitem.clear(); } catch (Exception e) { e.printStackTrace(); } listitem.addAll(bookingList); try { bookingList.clear(); } catch (Exception e) { e.printStackTrace(); } listitem.add(ib); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload