java - Andrioid listview only shows latest item -
java - Andrioid listview only shows latest item -
i populating listview items parse.com. working fine not long ago , reason 1 time changed eclipse android studio started showing latest item.
adapter
public class mycustomadapter extends parsequeryadapter<parseobject> { public mycustomadapter(context context) { super(context, "comments", r.layout.comments_listview_item); } @override public view getitemview(parseobject comment, view view, viewgroup parent) { view = view.inflate(getapplicationcontext(), r.layout.comments_listview_item, null); mlistviewreferences(view); loadcomments(); commenttext.settext(comment.getstring("comment")); commentersusername.settext(comment.getstring("commenter")); homecoming super.getitemview(comment, view, parent); } /** * set references */ private void mlistviewreferences(final view view) { commentersusername = (textview) view.findviewbyid(r.id.commentersusername); commenttext = (textview) view.findviewbyid(r.id.commenttext); } }
xml
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="0dp" android:padding="0dp"> <relativelayout android:id="@+id/relativelayout1" android:layout_width="match_parent" android:layout_height="50dp" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:layout_margin="0dp" android:background="@drawable/actionmenubackground"> <textview android:id="@+id/commenttext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centervertical="true" android:layout_marginleft="11dp" android:layout_torightof="@+id/comentfullname" android:text="comments" android:textcolor="@color/white" android:textsize="20sp" android:textstyle="bold" /> <imagebutton android:id="@+id/backbutton" android:layout_width="50dp" android:layout_height="match_parent" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:layout_margin="0dp" android:background="@null" android:src="@drawable/back_arrow" /> <textview android:id="@+id/comentfullname" android:layout_width="2dp" android:layout_height="30dp" android:layout_centervertical="true" android:layout_torightof="@+id/backbutton" android:background="#e0e0e0" /> </relativelayout> <edittext android:id="@+id/setcomment" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentleft="true" android:layout_aligntop="@+id/submitcomment" android:layout_toleftof="@+id/submitcomment" android:ems="10" android:hint="add comment" /> <imagebutton android:id="@+id/submitcomment" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignparentbottom="true" android:layout_alignparentright="true" android:background="@drawable/actionmenubackground" android:src="@drawable/commentsubmitarrow" /> <view android:id="@+id/view1" android:layout_width="match_parent" android:layout_height="1dp" android:layout_alignparentleft="true" android:layout_aligntop="@+id/setcomment" android:background="@color/green" /> <listview android:id="@+id/commentslistview" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignparentleft="true" android:divider="@null" android:dividerheight="5dp" android:clickable="false" android:listselector="@android:color/transparent" android:layout_below="@+id/relativelayout1" android:layout_above="@+id/setcomment" android:choicemode="none" /> </relativelayout>
here loadcomments method ();
void loadcomments() { runonuithread(new runnable() { @override public void run() { mycustomadapter adapter = new mycustomadapter(getapplicationcontext()); commentslistview.setadapter(adapter); } }); }
you should homecoming view
public view getitemview(parseobject comment, view view, viewgroup parent) { view = view.inflate(getapplicationcontext(), r.layout.comments_listview_item, null); mlistviewreferences(view); //loadcomments(); commenttext.settext(comment.getstring("comment")); commentersusername.settext(comment.getstring("commenter")); homecoming view; }
java android xml listview
Comments
Post a Comment