这是我的代码:
arrow.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
String user = user_name.getText().toString();
String pass = pass_word.getText().toString();
String check = db.getPassword(user);
if(check.equals(pass))
{
user_name.setVisibility(View.INVISIBLE);
pass_word.setVisibility(View.INVISIBLE);
arrow.setVisibility(View.INVISIBLE);
pg.setVisibility(View.VISIBLE);
for(int i=0;i<100000;i++)
{
pg.setVisibility(View.VISIBLE);
}
Intent openQr_code = new Intent ("com.cinamon.vampskin.MENU_ADMIN");
startActivity(openQr_code);
}
else
{
user_name.setVisibility(View.INVISIBLE);
pass_word.setVisibility(View.INVISIBLE);
arrow.setVisibility(View.INVISIBLE);
pg.setVisibility(View.VISIBLE);
for(int j=0;j<100000;j++)
{
pg.setVisibility(View.VISIBLE);
}
Toast.makeText(getApplicationContext(), "Invalid username or password", Toast.LENGTH_SHORT).show();
user_name.setVisibility(View.VISIBLE);
pass_word.setVisibility(View.VISIBLE);
arrow.setVisibility(View.VISIBLE);
pg.setVisibility(View.INVISIBLE);
noOfTimesLoginError++;
if(noOfTimesLoginError == 3)
{
Toast.makeText(getApplicationContext(), "Try again in 10 seconds...", Toast.LENGTH_LONG).show();
user_name.setVisibility(View.INVISIBLE);
pass_word.setVisibility(View.INVISIBLE);
arrow.setVisibility(View.INVISIBLE);
pg.setVisibility(View.VISIBLE);
time_text.setVisibility(View.VISIBLE);
for(int time = 10 ; time>0 ; time--)
{
for(int m = 0 ; m < 1000 ; m++)
{
time_text.setText("00 : 00 : "+time);
}
}
user_name.setVisibility(View.VISIBLE);
pass_word.setVisibility(View.VISIBLE);
arrow.setVisibility(View.VISIBLE);
pg.setVisibility(View.INVISIBLE);
time_text.setVisibility(View.INVISIBLE);
}
}
return false;
}
});
在其他部分,我想隐藏用户名字段、密码字段、图像箭头和 pg 是进度条,这些必须隐藏。在 for 循环之后只应该显示它,但是当我运行这段代码时,不可见的不工作,那些总是可见的。但在第一个 if 部分,根据代码可以完美地工作。
请帮忙,提前谢谢你:)