android - Listview style Each Row -
this code in custom adapter (the code in brown color) when list build proper margin applied valid items when scroll down , again scroll rows in list shifts margin left 20 i'm doing wrong please reply soon
@override public view getview(final int position, view convertview, viewgroup parent) { final viewholder holder; // getting data final viewmoviedetailsmodel_viewcomments movies = getitem(position); if (convertview == null) { convertview = view.inflate(context, r.layout.comment_row, null); holder = new viewholder(); //getting handles holder.comments_linearlayout = (linearlayout) convertview.findviewbyid(r.id.comments_linearlayout); holder.commenter_textview = (textview) convertview.findviewbyid(r.id.comment_row_commenter); holder.commented_on_textview = (textview) convertview.findviewbyid(r.id.comment_row_comment_time); holder.comment_text_textview = (textview) convertview.findviewbyid(r.id.comment_row_comment_text); holder.reply_button = (button) convertview.findviewbyid(r.id.comment_row_reply_button); convertview.settag(holder); } else { holder = (viewholder)convertview.gettag(); } if (movies != null) { if (((movies.getparent_comment_id()).tostring().equals("null")) && session.isloggedin()==true) { holder.reply_button.setvisibility(view.visible); }else{ holder.reply_button.setvisibility(view.invisible); } `if (!((movies.getparent_comment_id()).tostring().equals("null"))) { layoutparams params = new layoutparams(layoutparams.fill_parent,layoutparams.wrap_content); params.setmargins(20, 0, 0, 0); holder.comments_linearlayout.setlayoutparams(params); }` holder.commenter_textview.settext(movies.getusername_commentor()); holder.commenter_textview.settag(movies.getuser_id_commentor()); return convertview; }
because setting margins (the brown font) in 'if' statement:
if (movies != null)
just take out of if block (for example put before return point)
right code not executed @ first view load, since movie null. when getview called second time, movie not null, , marigin set according 'brown' code.
if not solution - maybe inside if statement condition not true (the 1 in first 'brown' row). so.. own logic prevents marigins set want :)
please let me know if helps.
Comments
Post a Comment