0
我想哟做一个for循环的重复块,但是,他们的一些价值观有所不同的xy位置,我如何使他们,使我仍然可以使用for循环,并以某种方式管理不同内部的for循环。这里XY位置是我的代码:如何在android中为以下代码制作动态循环?
m_views.add(hm7);
HeatMapElementView hm8 = (HeatMapElementView)view.findViewById(R.id.hmEle_08);
hm8.setTag(new Integer[]{Integer.valueOf(4),Integer.valueOf(2)});
hm8.setOnClickListener(
new OnClickListener(){
@Override
public void onClick(View vw){
if(isAnimating)
return;
RelativeLayout.LayoutParams relParams = (RelativeLayout.LayoutParams)m_hoverCraft.getLayoutParams();
//int xColumn = ((Integer[])vw.getTag())[0].intValue();
relParams.leftMargin = ((int)vw.getX())+((int)vw.getWidth()) - 450;
int yRow = ((Integer[])vw.getTag())[1].intValue();
relParams.topMargin = ((int)(vw.getHeight()*yRow) - (vw.getHeight()/2) - 162);
m_hoverCraft.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
m_hoverCraft.setTag(new float[]{1.0f,0.5f});
Animation anim = new ScaleAnimation(
0f, 1f, // Start and end values for the X axis scaling
0f, 1f, // Start and end values for the Y axis scaling
Animation.RELATIVE_TO_SELF, 1.0f, // Pivot point of X scaling
Animation.RELATIVE_TO_SELF, 0.5f);
showHoverView(vw,anim);
}
}
);
//hm8.setOnHoverListener(heatMapHover);
m_views.add(hm8);
HeatMapElementView hm9 = (HeatMapElementView)view.findViewById(R.id.hmEle_09);
hm9.setTag(new Integer[]{Integer.valueOf(1),Integer.valueOf(3)});
hm9.setOnClickListener(
new OnClickListener(){
@Override
public void onClick(View vw){
if(isAnimating)
return;
RelativeLayout.LayoutParams relParams = (RelativeLayout.LayoutParams)m_hoverCraft.getLayoutParams();
//int xColumn = ((Integer[])vw.getTag())[0].intValue();
relParams.leftMargin = (int)vw.getX();
int yRow = ((Integer[])vw.getTag())[1].intValue();
relParams.topMargin = ((int)(vw.getHeight()*yRow) - (vw.getHeight()/2) - 162);
m_hoverCraft.setTag(new float[]{0.0f,0.5f});
m_hoverCraft.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
Animation anim = new ScaleAnimation(
0f, 1f, // Start and end values for the X axis scaling
0f, 1f, // Start and end values for the Y axis scaling
Animation.RELATIVE_TO_SELF, 0.0f, // Pivot point of X scaling
Animation.RELATIVE_TO_SELF, 0.5f);
showHoverView(vw,anim);
}
}
);
//hm9.setOnHoverListener(heatMapHover);
m_views.add(hm9);
HeatMapElementView hm10 = (HeatMapElementView)view.findViewById(R.id.hmEle_10);
hm10.setTag(new Integer[]{Integer.valueOf(2),Integer.valueOf(3)});
hm10.setOnClickListener(
new OnClickListener(){
@Override
public void onClick(View vw){
if(isAnimating)
return;
RelativeLayout.LayoutParams relParams = (RelativeLayout.LayoutParams)m_hoverCraft.getLayoutParams();
//int xColumn = ((Integer[])vw.getTag())[0].intValue();
relParams.leftMargin = (int)vw.getX() + (int)vw.getWidth()/2 - 225;
int yRow = ((Integer[])vw.getTag())[1].intValue();
relParams.topMargin = ((int)(vw.getHeight()*yRow) - (vw.getHeight()/2) - 162);
m_hoverCraft.setTag(new float[]{0.5f,0.5f});
m_hoverCraft.setGravity(Gravity.CENTER);
Animation anim = new ScaleAnimation(
0f, 1f, // Start and end values for the X axis scaling
0f, 1f, // Start and end values for the Y axis scaling
Animation.RELATIVE_TO_SELF, 0.5f, // Pivot point of X scaling
Animation.RELATIVE_TO_SELF, 0.5f);
showHoverView(vw,anim);
}
}
);