Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd data in Refreshable Listview Android dynamically?
    primarykey
    data
    text
    <p>I want to add dynamic data from web service at the bottom of my list. and the list should refresh when i scrolls down the list to show the older messages..and load next page.. but my code is doing reverse i.e scrolling top to load next page and i am getting the older messages at first.. here is my code. if someone could help... </p> <pre><code> protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.conversations_activity); mListView.setOnScrollListener(new OnScrollListener() { int maxLoads = 30; @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem,visibleItemCount, int totalItemCount) { if ((totalItemCount - 1 &gt; maxLoads)&amp;&amp; ((totalItemCount - 1) % maxLoads == 0)) { System.gc(); } if (((firstVisibleItem + visibleItemCount) == totalItemCount) &amp;&amp; !isDataLoading &amp;&amp; isScrollingEnable) { new LoadNextPage(ConversationsActivity.this).execute(); } } }); new ConversationListTask(ConversationsActivity.this).execute(); } } private class ConversationListTask extends BaseAsyncTask { @Override protected void onPreExecute() { super.onPreExecute(); } public ConversationListTask(Activity activity) { super(activity); } @Override public void runDoInBackground() throws RuntimeException, Exception { isDataLoading = true; isScrollingEnable = false; mPageNumber = 0; try { listMessage = APIProcessor.listMessage(ConversationsActivity.this, "1", mPageNumber); } catch (Exception e) { e.printStackTrace(); } } @Override public void runOnPostExecute() { isDataLoading = false; isScrollingEnable = true; convoListAdapter = new ConversationListAdapter( ConversationsActivity.this, listMessage, urlThumbImageLoader); mListViewConversation.setAdapter(convoListAdapter); mListViewConversation.setSelection(mListViewConversation.getAdapter() .getCount() - 1); } } class LoadNextPage extends BaseAsyncTask { public LoadNextPage(Activity activity) { super(activity); setDefaultProgressDialogStatus(false); findViewById(R.id.list_loading_view).setVisibility(View.VISIBLE); } @Override public void runDoInBackground() throws RuntimeException, Exception { isDataLoading = true; tempList = APIProcessor.listMessage(ConversationsActivity.this, "1", mPageNumber + 1); } @Override public void runOnPostExecute() { new LoadNextPage(ConversationsActivity.this).execute(); findViewById(R.id.list_loading_view).setVisibility(View.GONE); isDataLoading = false; if (tempList == null || tempList.isEmpty() || listMessage == null || listMessage.isEmpty()) { } else { mPageNumber++; for (int i = 0; i &lt; tempList.size(); i++) { listMessage.add(tempList.get(i)); } convoListAdapter.notifyDataSetChanged(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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