Multiple items added to ListView (Android Studio) -


i seem have problem needs fixed. have listview assigned data xml code...

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical" >      <linearlayout         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:gravity="center|left"         android:padding="5dp" >          <imageview             android:id="@+id/ivimage"             android:layout_width="70dp"             android:layout_height="70dp"             android:src="@drawable/profile" />          <textview             android:id="@+id/tvfullname"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="textview"             android:textcolor="@android:color/white"             android:textsize="16sp"             android:paddingleft="5dp"             android:textstyle="bold" />         <textview             android:id="@+id/tvfullnametwo"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="textviewone"             android:textcolor="@android:color/white"             android:textsize="16sp"             android:paddingleft="5dp"             android:textstyle="bold" />      </linearlayout>  </linearlayout> 

and have java code assign data tvfullnametwo , tvfullname...

public view getview(int position, view convertview, viewgroup parent) {     view view = inflater.inflate(r.layout.relationship_inflater_two, null);     holder holder = new holder();     //connectordisconnectuser();     arraylist<string> listitems=new arraylist<string>();      holder.ivphoto = (imageview) view.findviewbyid(r.id.ivimage);     holder.tvfullname = (textview) view.findviewbyid(r.id.tvfullname);     holder.tvfullnametwo = (textview) view.findviewbyid(r.id.tvfullnametwo);     holder.tvfullnametwo.settext(usersinfo.get(position).get(relationshipremoved.likedtwo));     holder.tvfullname.settext(usersinfo.get(position).get(relationshipremoved.likedone));     /*imageloader.displayimage(             usersinfo.get(position).get(relationshipremoved.likedone),             holder.ivphoto);*/     //log.d("okhttp",usersinfo.get(position).get(     //        relationshipremoved.likedone));     return view; } 

when run code , usersinfo.get(position).get(relationshipremoved.likedtwo) = "test" , usersinfo.get(position).get(relationshipremoved.likedone) = "test".

i 2 items in listview...

testtest

testtest

how

test

test

one each textview.

adapter code...

public class relationshipadapterremoved extends baseadapter {     private instagramapp mapp;     private listview lvrelationshipalluser;     private arraylist<hashmap<string, string>> usersinfo;     private layoutinflater inflater;      //lvrelationshipalluser = (listview) findviewbyid(r.id.lvrelationship);     private imageloader imageloader;     context context;     public relationshipadapterremoved(context context,                                arraylist<hashmap<string, string>> usersinfo) {         inflater = (layoutinflater) context                 .getsystemservice(context.layout_inflater_service);         log.d("okhttp","debug4");         this.usersinfo = usersinfo;          this.imageloader = new imageloader(context);      } 

you need fix layout linearlayout has default orientaion of horizontal

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="horizontal" >          <imageview             android:id="@+id/ivimage"             android:layout_width="70dp"             android:layout_height="70dp"             android:src="@drawable/profile" />          <linearlayout             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:orientation="vertical"             android:padding="5dp" >              <textview                 android:id="@+id/tvfullname"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="textview"                 android:textcolor="@android:color/white"                 android:textsize="16sp"                 android:paddingleft="5dp"                 android:textstyle="bold" />              <textview                 android:id="@+id/tvfullnametwo"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="textviewone"                 android:textcolor="@android:color/white"                 android:textsize="16sp"                 android:paddingleft="5dp"                 android:textstyle="bold" />          </linearlayout>  </linearlayout> 

you need use java model class storing user info.

class user{         string name;         string fullname;          public string getname(){             return name;         }          public string getfullname(){             return fullname;         } 

}

then make list arraylist userlist = new arraylist<>();

and in adapter retrieve using userlist.get(position).getname();


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -