i using omeasure method find width of vew , returning correct values.
protected void onmeasure(int widthmeasurespec, int heightmeasurespec) { parentwidth = measurespec.getsize(widthmeasurespec); parentheight = measurespec.getsize(heightmeasurespec); this.setmeasureddimension( parentwidth, parentheight); //log.d("measure", "width = " + parentwidth + ", height = " //+ this.getmeasuredheight()); } now want use value parentwidth in following if statement
public void run() { a.flag2=true; while(a.flag2) { try { sleep(200); } catch(exception e) { } if(!a.flag1) { a.leftx+=10; a.rightx+=10; if(!a.flag3) { a.strt-=15; a.arc+=15; } else { a.strt+=15; a.arc-=15; } } if(a.flag1) { a.leftx-=10; a.rightx-=10; if(!a.flag3) a.arc+=15; if(a.flag3) a.arc-=15; } if(a.rightx==432) { a.topy+=60; a.bottomy+=60; a.flag1=true; a.strt=180; a.arc=315; } if(a.leftx==0) { a.topy+=60; a.bottomy+=60; a.flag1=false; a.strt=45; a.arc=315; } if(a.bottomy>=660) { a.topy=60; a.bottomy=120; } if(a.strt==0 || a.arc==360) { a.flag3=true; } if(a.strt==45 || a.arc==315) { a.flag3=false; } if(a.n3==a.rightx&&a.n5==(a.topy+a.bottomy)/2) { a.i+=1; int low=1; int high=10; a.n=a.r.nextint(high-low); a.n3=(a.n*10)+150; a.n5=(a.n*60)+90; a.f1=(float)a.n3; a.f2=(float)a.n5; } a.postinvalidate(); } } } this if statement defined inside thread class.but somehow value of parentwidth not being read her.if harcode "a.rightx==432" works.but dont want hardcode it. how should value of parentwidth in thread?
Comments
Post a Comment