how to Dynamically add custom row in ListView in android -


calling adapter list (adaptormessagelist) show 2 list...what want when clicking button , should add 1 new custom row dynamically me... have checked out on google , took me hours not being able it..

                        string[] name = {"hello","how "};                         string[] address = {"mustang","josmoms"};                         int[] img = {r.drawable.b,r.drawable.b};                     adaptormessagelist adaptor = new adaptormessagelist(getcontext(),name,address,img);                     messagelistview.setadapter(adaptor);                     }             });         }           class adaptormessagelist extends arrayadapter<string> {                 context context;                 string[] profile_name;                 string[] profile_hometown;                 int[] profile_picture;                 adaptormessagelist(context c,string[] profile_name,string[] profile_hometown,int[] profile_picture){                     super(c,r.layout.single_row_comm_user_list,r.id.profile_name,profile_name);                     context=c;                     this.profile_name = profile_name;                     this.profile_hometown = profile_hometown;                     this.profile_picture = profile_picture;                 }                  @override                 public view getview(int position, view convertview, viewgroup parent) {                     layoutinflater inflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service);                     view row= inflater.inflate(r.layout.single_row_comm_user_list,parent,false);                     textview tprofile_name = (textview) row.findviewbyid(r.id.profile_name);                     textview tprofile_hometown = (textview) row.findviewbyid(r.id.profile_hometown);                     imageview tprofile_picture = (imageview) row.findviewbyid(r.id.profile_picture);                     tprofile_name.settext(profile_name[position]);                     tprofile_hometown.settext(profile_hometown[position]);                     tprofile_picture.setimageresource(profile_picture[position]);                     return row;                 }             } 

add data in adapter on itemview click , notify change using notifydatasetchanged.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -