我有 5 个图像按钮,我想按降序使它们可见和不可见。就像 5,4,3,2,1 这样就完成了。但是当我来到 ImageButton1 时,我无法再次使其不可见。因为该按钮上同时运行了两个条件。一个使 2,3,4,5 按钮不可见,另一个使 Imagebutton1 不可见。那我该怎么办?
imgmilku1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
imgmilks1.setVisibility(View.VISIBLE);
imgmilks2.setVisibility(View.INVISIBLE);
imgmilks3.setVisibility(View.INVISIBLE);
imgmilks4.setVisibility(View.INVISIBLE);
imgmilks5.setVisibility(View.INVISIBLE);
imgmilks3.setVisibility(View.INVISIBLE);
imgmilku1.setVisibility(View.INVISIBLE);
imgmilku2.setVisibility(View.VISIBLE);
imgmilku3.setVisibility(View.VISIBLE);
imgmilku4.setVisibility(View.VISIBLE);
imgmilku5.setVisibility(View.VISIBLE);
firstglass = 1 * 300;
}
});
imgmilks1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
// imgmilks1.setVisibility(View.VISIBLE);
// imgmilku1.setVisibility(View.INVISIBLE);
imgmilks4.setVisibility(View.INVISIBLE);
imgmilku4.setVisibility(View.VISIBLE);
imgmilks5.setVisibility(View.INVISIBLE);
imgmilku5.setVisibility(View.VISIBLE);
imgmilks3.setVisibility(View.INVISIBLE);
imgmilku3.setVisibility(View.VISIBLE);
imgmilks2.setVisibility(View.INVISIBLE);
imgmilku2.setVisibility(View.VISIBLE);
firstglass = 1 * 300;
}
});
imgmilku2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
imgmilks1.setVisibility(View.VISIBLE);
imgmilks2.setVisibility(View.VISIBLE);
imgmilks3.setVisibility(View.INVISIBLE);
imgmilku4.setVisibility(View.VISIBLE);
imgmilku1.setVisibility(View.INVISIBLE);
imgmilku2.setVisibility(View.INVISIBLE);
imgmilku3.setVisibility(View.VISIBLE);
secondglass = 2 * 300;
}
});
imgmilks2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
imgmilks4.setVisibility(View.INVISIBLE);
imgmilku4.setVisibility(View.VISIBLE);
imgmilks5.setVisibility(View.INVISIBLE);
imgmilku5.setVisibility(View.VISIBLE);
imgmilks3.setVisibility(View.INVISIBLE);
imgmilku3.setVisibility(View.VISIBLE);
secondglass = 2 * 300;
}
});
imgmilku3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
imgmilks1.setVisibility(View.VISIBLE);
imgmilks2.setVisibility(View.VISIBLE);
imgmilks3.setVisibility(View.VISIBLE);
imgmilku4.setVisibility(View.VISIBLE);
imgmilku1.setVisibility(View.INVISIBLE);
imgmilku2.setVisibility(View.INVISIBLE);
imgmilku3.setVisibility(View.INVISIBLE);
thirdglass = 3 * 300;
}
});
imgmilks3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
imgmilks4.setVisibility(View.INVISIBLE);
imgmilku4.setVisibility(View.VISIBLE);
imgmilks5.setVisibility(View.INVISIBLE);
imgmilku5.setVisibility(View.VISIBLE);
fourtglass = 0;
thirdglass = 3 * 300;
}
});
imgmilku4.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
imgmilks1.setVisibility(View.VISIBLE);
imgmilks2.setVisibility(View.VISIBLE);
imgmilks3.setVisibility(View.VISIBLE);
imgmilks4.setVisibility(View.VISIBLE);
imgmilku1.setVisibility(View.INVISIBLE);
imgmilku2.setVisibility(View.INVISIBLE);
imgmilku3.setVisibility(View.INVISIBLE);
imgmilku4.setVisibility(View.INVISIBLE);
fourtglass = 4 * 300;
}
});
imgmilks4.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
imgmilks5.setVisibility(View.INVISIBLE);
imgmilku5.setVisibility(View.VISIBLE);
fifthglass = 0;
fourtglass = 4 * 300;
}
});
imgmilku5.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
imgmilks5.setVisibility(View.VISIBLE);
imgmilks4.setVisibility(View.VISIBLE);
imgmilks3.setVisibility(View.VISIBLE);
imgmilks2.setVisibility(View.VISIBLE);
imgmilks1.setVisibility(View.VISIBLE);
imgmilku5.setVisibility(View.INVISIBLE);
imgmilku4.setVisibility(View.INVISIBLE);
imgmilku3.setVisibility(View.INVISIBLE);
imgmilku2.setVisibility(View.INVISIBLE);
imgmilku1.setVisibility(View.INVISIBLE);
firstglass = 0;
secondglass = 0;
thirdglass = 0;
fourtglass = 0;
fifthglass = 5 * 300;
}
});