예제 #1
0
  public void showProgressBar() {
    AnimationSet set = new AnimationSet(true);

    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(500);
    set.addAnimation(animation);

    animation =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF,
            0.0f,
            Animation.RELATIVE_TO_SELF,
            0.0f,
            Animation.RELATIVE_TO_SELF,
            -1.0f,
            Animation.RELATIVE_TO_SELF,
            0.0f);
    animation.setDuration(500);
    set.addAnimation(animation);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    RelativeLayout loading = (RelativeLayout) findViewById(R.id.loading);
    loading.setVisibility(View.VISIBLE);
    loading.setLayoutAnimation(controller);
  }
예제 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    extras = getIntent().getExtras();
    if (extras != null) {
      try {
        LayoutInflater factory = LayoutInflater.from(LoginActivity.this);
        final RelativeLayout layout = (RelativeLayout) factory.inflate(R.layout.login, null);

        String animation = extras.getString("animation");
        // 得到一个LayoutAnimationController对象;
        if (animation.equals("left")) {
          controller = AnimationUtils.loadLayoutAnimation(this, R.anim.layout_left_in);
        } else {
          controller = AnimationUtils.loadLayoutAnimation(this, R.anim.layout_right_in);
        }
        // 设置控件显示的顺序;
        controller.setOrder(LayoutAnimationController.ORDER_REVERSE);
        // 设置控件显示间隔时间;
        controller.setDelay(0);
        // 为ListView设置LayoutAnimationController属性;
        layout.setLayoutAnimation(controller);
        setContentView(layout);
      } catch (Exception e) {
        // TODO: handle exception
        setContentView(R.layout.login);

        String id = extras.getString("id");
        String pwd = extras.getString("pwd");

        System.out.println(id);
        System.out.println(pwd);

        login(id, pwd);
      }
    } else {
      setContentView(R.layout.login);
    }

    mGestureDetector = new GestureDetector(this, (OnGestureListener) this);

    _id = (EditText) findViewById(R.id.id_edit);
    _pwd = (EditText) findViewById(R.id.pwd_edit);

    final Button _backButton = (Button) findViewById(R.id.back_button);
    final Button _loginButton = (Button) findViewById(R.id.login_button);
    final Button _forgetButton = (Button) findViewById(R.id.forget_button);
    final Button _show_hide_Button = (Button) findViewById(R.id.show_hide_button);

    // final ProgressBar bar = (ProgressBar) findViewById(R.id.login_pb);

    _backButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {

            // TODO Auto-generated method stub
            Intent intent = new Intent(LoginActivity.this, EnterActivity.class);
            startActivity(intent);
            LoginActivity.this.finish();
          }
        });

    _loginButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            System.out.println("Python: " + _id.getText().toString());
            System.out.println("FWL: " + _pwd.getText().toString());
            login(_id.getText().toString(), _pwd.getText().toString());
          }
        });

    _forgetButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {

            // TODO Auto-generated method stub
            Intent intent = new Intent(LoginActivity.this, ForgetPwdActivity.class);
            startActivity(intent);
            LoginActivity.this.finish();
          }
        });

    _show_hide_Button.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
              if (0 == showorhide) {
                _pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                _show_hide_Button.setText(getString(R.string._hidepwd));
                showorhide = 1;
              } else {
                _pwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
                _show_hide_Button.setText(getString(R.string._showpwd));
                showorhide = 0;
              }
            } else {
              // do nothing
            }
            return false;
          }
        });

    /*
     _showpwdButton.setOnClickListener(new OnClickListener() {

    	@Override
    	public void onClick(View v) {
    		// TODO Auto-generated method stub
    		if (((CheckBox) v).isChecked()) {
    			System.out.println("Checked");
    			_pwd.setTransformationMethod(HideReturnsTransformationMethod
    					.getInstance());
    		} else {
    			System.out.println("Not Checked");
    			_pwd.setTransformationMethod(PasswordTransformationMethod
    					.getInstance());
    		}

    	}
    });
    */
  }