android - Andrioid - Unable to re-create Canvas View dynamically -


i trying show gridview of canvas images drawn in previous screen. have set of different views drawn in first screen , views subjected change, canvas re drawn according user's actions. have 5 heart shaped canvas views , using different views every heart meaning not using same class draw 5 hearts, rather using 5 different class 5 different hearts. these hearts filled color on user click. in next page, trying view hearts drawn in previous page , there no action involved here, in sense page solely purpose of viewing. this page can contain n number of hearts previous page have 5 hearts @ instant. purpose, using single view in display page display hearts. last drawn heart , other previous hearts getting overriden.

my idea of filling heart drawing rectangle on , clipping path.

my ondraw :

        path.moveto(left_x_moveto, left_y_moveto);         path.cubicto(left_x1,left_y1,left_x2,left_y2,left_x3,left_y3);          path.moveto(left_x_moveto, left_y_moveto);         path.cubicto(right_x1,right_y1,right_x2,right_y2,right_x3,right_y3);           this.setdrawingcacheenabled(true);         rect = new rect((int)(canvas.getwidth()*.10),(int)(canvas.getheight()*filled_amount),(int) canvas.getwidth(), (int) canvas.getheight());          canvas.clippath(path);          paint.setcolor(color.white);         paint.setstyle(paint.style.fill);         canvas.drawpath(path, paint);         canvas.drawrect(rect, rect_paint);          heart_outline_paint.setcolor(getresources().getcolor(r.color.heart_outline_color)); // change boundary color         heart_outline_paint.setstrokewidth(15);         heart_outline_paint.setstyle(paint.style.stroke);         canvas.drawpath(path, heart_outline_paint); 

the part add views arraylist of views :

public static arraylist<view> heart_views = new arraylist<view>();  for(int i=0;i<dbhelper.getheartpercentagesforsummary().size();i++)         {             summaryheartshape.filled_amount = .90 - (dbhelper.getheartpercentagesforsummary().get(i)*0.008);             summaryheartshape summary_heart_shape = new summaryheartshape(getactivity());             summary_heart_shape.invalidate();             heart_views.add(summary_heart_shape);         } 

i presume ondraw() called when create instance of summaryheartshape class.

so can see, everytime filling rectangle different height given summaryheartshape.filled_amount , static variable assigned in ondraw of rect

rect = new rect((int)(canvas.getwidth()*.10),(int)(canvas.getheight()*filled_amount),(int) canvas.getwidth(), (int) canvas.getheight());

so means rect drawn according height give , differs every time, should receiving canvas view rectangle height every time getting same rectangle same height.

my screen user can fill heart - filling heart

my screen user can view filled heart - summary of hearts

as can see hearts in first page filled right hearts in second page showing last filled hearts.

i have checked values gets passed summaryheartshape.filled_amount, different time though hearts broken !!!!

can please me in fixing heart ? please feel free ask doubts or if want make more clear.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -