Android ListView scrolls slowly -


i have listview , connected database using cursor adapter. scrolling fine previously. scrolls slow , throws message in log

i/choreographer﹕ skipped 115 frames!  application may doing work on main thread. 

how can trace causes slowness?

getview code

@override public view getview(final int position, view convertview, viewgroup parent) {     context = parent.getcontext();     view vi = super.getview(position, convertview, parent);      image_comment = (imageview) vi.findviewbyid(r.id.outbox_comment);     image_more = (imageview) vi.findviewbyid(r.id.outbox_details);     feedbacktext = (textview) vi.findviewbyid(r.id.outbox_feedback_text);     relativelayout outbox_bg = (relativelayout) vi.findviewbyid(r.id.outbox_msg_layout);     linearlayout outbox_option = (linearlayout) vi.findviewbyid(r.id.outbox_option_layout);     avatartext = (textview) vi.findviewbyid(r.id.avatar_text);     avatarimage = (imageview) vi.findviewbyid(r.id.avatar_image);     avatartext.setvisibility(view.gone);     avatarimage.setvisibility(view.gone);     mywebview = (webview) vi.findviewbyid(r.id.out_webview);     mywebview.setvisibility(view.gone);     askfeedbackanswer = (textview) vi.findviewbyid(r.id.ask_feedback_answer_text);      pollchoice1 = (textview) vi.findviewbyid(r.id.poll_choice1);     pollchoice2 = (textview) vi.findviewbyid(r.id.poll_choice2);     pollchoice3 = (textview) vi.findviewbyid(r.id.poll_choice3);     pollchoice4 = (textview) vi.findviewbyid(r.id.poll_choice4);     pollchoice5 = (textview) vi.findviewbyid(r.id.poll_choice5);      lockimage = (imageview) vi.findviewbyid(r.id.lock_image);     pollvisible = (imageview) vi.findviewbyid(r.id.poll_visible);      starwhite1 = (imageview) vi.findviewbyid(r.id.star_white_first);     starwhite2 = (imageview) vi.findviewbyid(r.id.star_white_second);     starwhite3 = (imageview) vi.findviewbyid(r.id.star_white_third);     starwhite4 = (imageview) vi.findviewbyid(r.id.star_white_fourth);     starwhite5 = (imageview) vi.findviewbyid(r.id.star_white_fifth);      greentick1 = (imageview) vi.findviewbyid(r.id.green_tick1);     greentick2 = (imageview) vi.findviewbyid(r.id.green_tick2);     greentick3 = (imageview) vi.findviewbyid(r.id.green_tick3);     greentick4 = (imageview) vi.findviewbyid(r.id.green_tick4);     greentick5 = (imageview) vi.findviewbyid(r.id.green_tick5);      final messagethread message = messagethreaddbaction.getmessagefromcursor(getcursor());      resources res = context.getresources();     avatars = res.getstringarray(r.array.avatar);     avatarcolors = res.getstringarray(r.array.colors);     redarray = res.getintarray(r.array.red_array);     greenarray = res.getintarray(r.array.green_array);     bluearray = res.getintarray(r.array.blue_array);      int avatarindex = message.geticon() - 1;     int avatarcolorindex = message.geticoncolor() - 1;     if (avatarindex > 0 && avatarcolorindex > 0) {         string avatarname = avatars[avatarindex];         string avatarcolor = avatarcolors[avatarcolorindex];         int avatar_id = getdrawable(context, "avatar" + (avatarindex + 1));         int shape_id = getdrawable(context, "round" + (avatarcolorindex + 1));         avatartext.settext(avatarcolor + "_" + avatarname);         avatarimage.setimageresource(avatar_id);         drawable drawable = res.getdrawable(shape_id);         avatarimage.setbackgrounddrawable(drawable);      }      int padding_in_dp = 15;  // 6 dps     final float scale = activity.getresources().getdisplaymetrics().density;     int padding_in_px = (int) (padding_in_dp * scale + 0.5f);      pollchoice1.settypeface(null, typeface.normal);     pollchoice2.settypeface(null, typeface.normal);     pollchoice3.settypeface(null, typeface.normal);     pollchoice4.settypeface(null, typeface.normal);     pollchoice5.settypeface(null, typeface.normal);      pollchoice1.settextsize(18);     pollchoice2.settextsize(18);     pollchoice3.settextsize(18);     pollchoice4.settextsize(18);     pollchoice5.settextsize(18);      pollchoice1.setenabled(true);     pollchoice2.setenabled(true);     pollchoice3.setenabled(true);     pollchoice4.setenabled(true);     pollchoice5.setenabled(true);      pollchoice1.settextcolor((color.parsecolor("#838383")));     pollchoice2.settextcolor((color.parsecolor("#838383")));     pollchoice3.settextcolor((color.parsecolor("#838383")));     pollchoice4.settextcolor((color.parsecolor("#838383")));     pollchoice5.settextcolor((color.parsecolor("#838383")));      if(message.gettype() == messagethread.out_message){         pollchoice1.setenabled(false);         pollchoice2.setenabled(false);         pollchoice3.setenabled(false);         pollchoice4.setenabled(false);         pollchoice5.setenabled(false);     }      if (message.getanswered() || (message.gettype() == messagethread.out_message)) {         string answer_string = message.getanswer();         if (message.isquiz()) {             int correctanswer = message.getcorrectanswer();              if (correctanswer == 0) {                 pollchoice1.settextcolor((color.parsecolor("#838383")));                 greentick1.setvisibility(view.visible);             } else if (correctanswer == 1) {                 pollchoice2.settextcolor((color.parsecolor("#838383")));                 greentick2.setvisibility(view.visible);             } else if (correctanswer == 2) {                 pollchoice3.settextcolor((color.parsecolor("#838383")));                 greentick3.setvisibility(view.visible);             } else if (correctanswer == 3) {                 pollchoice4.settextcolor((color.parsecolor("#838383")));                 greentick4.setvisibility(view.visible);             } else if (correctanswer == 4) {                 pollchoice5.settextcolor((color.parsecolor("#838383")));                 greentick5.setvisibility(view.visible);             }         }          if (answer_string != null) {             int answer = integer.parseint(answer_string);             if (message.getpolltype().equals("score")) {                 starwhite1.setbackground(null);                 starwhite2.setbackground(null);                 starwhite3.setbackground(null);                 starwhite4.setbackground(null);                 starwhite5.setbackground(null);                  if (answer == 1) {                     starwhite1.setbackground(activity.getresources().getdrawable(r.drawable.textlines));                 } else if (answer == 2) {                     starwhite2.setbackground(activity.getresources().getdrawable(r.drawable.textlines));                 } else if (answer == 3) {                     starwhite3.setbackground(activity.getresources().getdrawable(r.drawable.textlines));                 } else if (answer == 4) {                     starwhite4.setbackground(activity.getresources().getdrawable(r.drawable.textlines));                 } else if (answer == 5) {                     starwhite5.setbackground(activity.getresources().getdrawable(r.drawable.textlines));                 }             } else {                 if (answer == 0) {                     pollchoice1.settextcolor((color.parsecolor("#ffcc33")));                 } else if (answer == 1) {                     pollchoice2.settextcolor((color.parsecolor("#ffcc33")));                 } else if (answer == 2) {                     pollchoice3.settextcolor((color.parsecolor("#ffcc33")));                 } else if (answer == 3) {                     pollchoice4.settextcolor((color.parsecolor("#ffcc33")));                 } else if (answer == 4) {                     pollchoice5.settextcolor((color.parsecolor("#ffcc33")));                 }             }         }     } else {         pollchoice1.setenabled(true);         pollchoice2.setenabled(true);         pollchoice3.setenabled(true);         pollchoice4.setenabled(true);         pollchoice5.setenabled(true);     }      lockimage.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             string displaytext = "this ";             if (message.getscope().equals("domain")) {                 displaytext = displaytext + "public ";             } else {                 displaytext = displaytext + "private ";             }              if (message.isquiz()) {                 displaytext = displaytext + "quiz";             } else {                 displaytext = displaytext + "poll";             }              toast toast = toast.maketext(context.getapplicationcontext(),                     displaytext, toast.length_short);             toast.setgravity(gravity.center_vertical | gravity.center_horizontal, 0, 0);             toast.show();         }     });      pollvisible.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             string displaytext = "";             if (message.getvisibility().equals("public")) {                 displaytext = "aggregate answer visible";             } else {                 displaytext = "aggregate answer not visible";             }              toast = toast.maketext(context.getapplicationcontext(),                     displaytext, toast.length_short);             toast.setgravity(gravity.center_vertical | gravity.center_horizontal, 0, 0);             toast.show();           }     });      feedbacktypeicon.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             string displaytext = "";             if (message.isquiz()) {                 displaytext = "this quiz";             } else if (message.ispoll()) {                 displaytext = "this poll";             } else {                 if (message.isaskforfeedback() || (!stringutility.isnullorempty(message.getsolicitationid()) && !message.equals("null")))                 {                     if(message.gettype() == messagethread.in_message) {                         string requestor[] = message.getrequestor().trim().split("@");                         displaytext = requestor[0]+ " asking feedback";                     }                     else{                         displaytext = "feedback have requested";                     }                  } else {                     if(message.gettype() == messagethread.in_message){                         displaytext = "feedback received";                     }                     else{                         displaytext = "feedback sent";                     }                  }             }              toast = toast.maketext(context.getapplicationcontext(),                     displaytext, toast.length_short);             toast.setgravity(gravity.center_vertical | gravity.center_horizontal, 0, 0);             toast.show();           }     });      message.setrandomcode(stringutility.generaterandomdigits(6));      pollchoice1.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             if(message.getanswered()){                 if(message.getscope().equals("private") && message.getresponsecount() < 1){                     showalert("not enough people have responded display answers");                 }             }             else{                 message.setanswered(true);                 if((message.getscope().equals("private") && message.getresponsecount() > 0) || message.getscope().equals("domain")){                     message.setoption1count(message.getoption1count() + 1);                     message.setresponsecount(message.getresponsecount() + 1);                 }                  message.setanswer("" + 0);                 action.update(message);             }             pollreplyasynctask asynctask = new pollreplyasynctask(activity, false, message, message.getuserid());             asynctask.execute();         }     });      pollchoice2.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             if(message.getanswered()){                 if(message.getscope().equals("private") && message.getresponsecount() < 1){                     showalert("not enough people have responded display answers");                 }             }             else{                 message.setanswered(true);                 message.setanswer("" + 1);                 if((message.getscope().equals("private") && message.getresponsecount() > 0) || message.getscope().equals("domain")){                     message.setoption2count(message.getoption2count() + 1);                     message.setresponsecount(message.getresponsecount() + 1);                 }                 action.update(message);             }             pollreplyasynctask asynctask = new pollreplyasynctask(activity, false, message, message.getuserid());             asynctask.execute();         }     });      pollchoice3.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             if(message.getanswered()){                 if(message.getscope().equals("private") && message.getresponsecount() < 1){                     showalert("not enough people have responded display answers");                 }             }             else{                 message.setanswered(true);                 message.setanswer("" + 2);                 if((message.getscope().equals("private") && message.getresponsecount() > 0) || message.getscope().equals("domain")){                     message.setoption3count(message.getoption3count() + 1);                     message.setresponsecount(message.getresponsecount() + 1);                 }                 action.update(message);             }             pollreplyasynctask asynctask = new pollreplyasynctask(activity, false, message, message.getuserid());             asynctask.execute();         }     });      pollchoice4.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             if(message.getanswered()){                 if(message.getscope().equals("private") && message.getresponsecount() < 1){                     showalert("not enough people have responded display answers");                 }             }             else{                 message.setanswered(true);                 message.setanswer("" + 3);                 if((message.getscope().equals("private") && message.getresponsecount() > 0) || message.getscope().equals("domain")){                     message.setoption4count(message.getoption4count() + 1);                     message.setresponsecount(message.getresponsecount() + 1);                 }                 action.update(message);             }             pollreplyasynctask asynctask = new pollreplyasynctask(activity, false, message, message.getuserid());             asynctask.execute();         }     });      pollchoice5.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             if(message.getanswered()){                 if(message.getscope().equals("private") && message.getresponsecount() < 1){                     showalert("not enough people have responded display answers");                 }             }             else{                 message.setanswered(true);                 message.setanswer("" + 4);                 if((message.getscope().equals("private") && message.getresponsecount() > 0) || message.getscope().equals("domain")){                     message.setoption5count(message.getoption5count() + 1);                     message.setresponsecount(message.getresponsecount() + 1);                 }                 action.update(message);             }             pollreplyasynctask asynctask = new pollreplyasynctask(activity, false, message, message.getuserid());             asynctask.execute();         }     });      starwhite1.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             if (!message.getanswered()) {                 message.setanswered(true);                 message.setanswer("" + 1);                 if((message.getscope().equals("private") && message.getresponsecount() > 0) || message.getscope().equals("domain")){                     message.setoption1count(message.getoption1count() + 1);                     message.setresponsecount(message.getresponsecount() + 1);                 }                 action.update(message);             }             else{                 if(message.getscope().equals("private") && message.getresponsecount() < 1){                     showalert("not enough people have responded display answers");                 }             }             pollreplyasynctask asynctask = new pollreplyasynctask(activity, false, message, message.getuserid());             asynctask.execute();         }     });      starwhite2.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             if (!message.getanswered()) {                 message.setanswered(true);                 message.setanswer("" + 2);                  if((message.getscope().equals("private") && message.getresponsecount() > 0) || message.getscope().equals("domain")){                     message.setoption2count(message.getoption2count() + 1);                     message.setresponsecount(message.getresponsecount() + 1);                 }                 action.update(message);             }             else{                 if(message.getscope().equals("private") && message.getresponsecount() < 1){                     showalert("not enough people have responded display answers");                 }             }             pollreplyasynctask asynctask = new pollreplyasynctask(activity, false, message, message.getuserid());             asynctask.execute();         }     });      starwhite3.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             if (!message.getanswered()) {                 message.setanswered(true);                 message.setanswer("" + 3);                 if((message.getscope().equals("private") && message.getresponsecount() > 0) || message.getscope().equals("domain")){                     message.setoption3count(message.getoption3count() + 1);                     message.setresponsecount(message.getresponsecount() + 1);                 }                 action.update(message);             }             else{                 if(message.getscope().equals("private") && message.getresponsecount() < 1){                     showalert("not enough people have responded display answers");                 }             }             pollreplyasynctask asynctask = new pollreplyasynctask(activity, false, message, message.getuserid());             asynctask.execute();         }     });      starwhite4.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             if (!message.getanswered()) {                 message.setanswered(true);                 message.setanswer("" + 4);                  if((message.getscope().equals("private") && message.getresponsecount() > 0) || message.getscope().equals("domain")){                     message.setoption4count(message.getoption4count() + 1);                     message.setresponsecount(message.getresponsecount() + 1);                 }                 action.update(message);             }             else{                 if(message.getscope().equals("private") && message.getresponsecount() < 1){                     showalert("not enough people have responded display answers");                 }             }             pollreplyasynctask asynctask = new pollreplyasynctask(activity, false, message, message.getuserid());             asynctask.execute();         }     });      starwhite5.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             if (!message.getanswered()) {                 message.setanswered(true);                 message.setanswer("" + 5);                  if((message.getscope().equals("private") && message.getresponsecount() > 0) || message.getscope().equals("domain")){                     message.setoption5count(message.getoption5count() + 1);                     message.setresponsecount(message.getresponsecount() + 1);                 }                 action.update(message);              }             else{                 if(message.getscope().equals("private") && message.getresponsecount() < 1){                     showalert("not enough people have responded display answers");                 }             }             pollreplyasynctask asynctask = new pollreplyasynctask(activity, false, message, message.getuserid());             asynctask.execute();         }     });      emailcount.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             intent = new intent(activity.getapplicationcontext(), recipientlistactivity.class);             i.putextra(appconstants.intent_value_userid, message.getuserid());             i.putextra(appconstants.intent_value_threadid, message.getthreadid());             activity.startactivity(i);         }     });      askfeedbackanswer.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             intent = new intent(activity.getapplicationcontext(),                     inboxdetailactivity.class);             i.putextra(appconstants.intent_value_userid,                     message.getuserid());             i.putextra(appconstants.intent_value_threadid,                     message.getthreadid());             i.putextra(appconstants.intent_value_threadtype,                     message.gettype());             i.putextra("curs", string.valueof((integer) v.gettag()));             i.putextra("type_comment", "true");             activity.startactivity(i);         }     });       if (message.gettype() == messagethread.out_message) {   //            outbox_bg.setpadding(padding_in_px, padding_in_px, padding_in_px, padding_in_px);          image_like = (imageview) vi.findviewbyid(r.id.outbox_like);         image_dislike = (imageview) vi.findviewbyid(r.id.outbox_dislike);          image_like.setenabled(false);         image_dislike.setenabled(false);          mywebview.setvisibility(view.gone);         outbox_option.setvisibility(view.visible);         feedbacktext.setvisibility(view.visible);          image_more.setonclicklistener(new onclicklistener() {             @override             public void onclick(view v) {                 if (!message.ispoll()) {                     if (message.isclosed()) {                         apputils.showerror(activity,                                 "this thread has been closed");                     } else if (message.isblocked()) {                         apputils.showerror(activity,                                 "this thread has been blocked");                     } else {                         showcontextmenu(message, v);                     }                 }             }         });          image_comment.setonclicklistener(new onclicklistener() {             @override             public void onclick(view v) {                  if (message.isclosed()) {                     apputils.showerror(activity,                             "this thread has been closed");                 } else if (message.isblocked()) {                     apputils.showerror(activity,                             "this thread has been blocked");                 } else {                     intent = new intent(activity.getapplicationcontext(),                             outboxdetailactivity.class);                     i.putextra(appconstants.intent_value_userid,                             message.getuserid());                     i.putextra(appconstants.intent_value_threadid,                             message.getthreadid());                     i.putextra(appconstants.intent_value_threadtype,                             message.gettype());                     i.putextra("via_comment", true);                     int purpose = getcursor().getposition();                     //                  purpose=purpose+1;                     i.putextra("curs", string.valueof(purpose));                     i.putextra("type_comment", "true");                     activity.startactivity(i);                 }             }         });          } else {             mywebview.setvisibility(view.gone);             outbox_option.setvisibility(view.visible);             feedbacktext.setvisibility(view.visible);              image_like = (imageview) vi.findviewbyid(r.id.outbox_like);             image_dislike = (imageview) vi.findviewbyid(r.id.outbox_dislike);             if (!message.ispoll() && !message.isaskforfeedback()) {                 image_like.setvisibility(view.visible);                 image_dislike.setvisibility(view.visible);                 image_like.setenabled(true);                 image_dislike.setenabled(true);             } else {                 image_like.setvisibility(view.          }     }      return vi; } 

use run on ui thread.

 someactivity.runonuithread(new runnable() {     @override     public void run() {        //your code run in gui thread here     }//public void run() {  }); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -