我有一个ListView
项,我从Web API的JSON响应中获取它们。它基本上都有评论。问题是当用户添加新评论时,该项目将添加到列表的顶部。我希望最后添加该项目。
这是我的代码: -
MyList.java
private void GetComments()
{
// TODO Auto-generated method stub
scrollNews.scrollTo(0, scrollNews.getBottom());
commentsList.setVisibility(View.VISIBLE);
String items;
try
{
String getRequestForComments = myUrl;
items = new FetchItems().execute(getRequestForComments).get();
ArrayList<HashMap<String, String>> getList = new GetList().execute(items).get();
itemsAdapter = (ListAdapter) new CommentsAdapter(NewsDetails.this, getList);
commentsList.setAdapter(itemsAdapter);
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (ExecutionException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
mylist.xml
<ListView
android:id="@+id/android:list"
android:visibility="invisible"
android:transcriptMode="alwaysScroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/getdata"
android:divider="#b5b5b5"
android:dividerHeight="1dp"
android:layout_weight="6"
android:layout_gravity="bottom"
android:listSelector="@drawable/list_selector"
android:padding="5dp"/>
任何人都可以帮我吗?