@Override protected void initView(Bundle savedInstanceState) { listView = (ListView) findViewById(R.id.listView); List<String> list = new ArrayList<String>(); for (int i = 0; i < 20; i++) { list.add("数据" + i); } ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list); listView.setAdapter(adapter); LayoutAnimationController lac = new LayoutAnimationController(AnimationUtils.loadAnimation(this, R.anim.zoom_in)); lac.setOrder(LayoutAnimationController.ORDER_NORMAL); listView.setLayoutAnimation(lac); listView.startLayoutAnimation(); }
@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()); } } }); */ }
@Override public View onCreateView() { LinearLayout ll_container = new LinearLayout(context); ll_container.setOrientation(LinearLayout.VERTICAL); ll_container.setBackgroundColor(Color.TRANSPARENT); /** title */ tv_title = new TextView(context); tv_title.setGravity(Gravity.CENTER); tv_title.setPadding(dp2px(10), dp2px(5), dp2px(10), dp2px(5)); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params.topMargin = dp2px(20); ll_container.addView(tv_title, params); /** title underline */ v_line_title = new View(context); ll_container.addView(v_line_title); /** listview */ lv = new ListView(context); lv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1)); lv.setCacheColorHint(Color.TRANSPARENT); lv.setFadingEdgeLength(0); lv.setVerticalScrollBarEnabled(false); lv.setSelector(new ColorDrawable(Color.TRANSPARENT)); ll_container.addView(lv); /** cancel btn */ tv_cancel = new TextView(context); tv_cancel.setGravity(Gravity.CENTER); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.topMargin = dp2px(7); lp.bottomMargin = dp2px(7); tv_cancel.setLayoutParams(lp); ll_container.addView(tv_cancel); /** LayoutAnimation */ TranslateAnimation animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 6f, Animation.RELATIVE_TO_SELF, 0); animation.setInterpolator(new DecelerateInterpolator()); animation.setDuration(350); animation.setStartOffset(150); lac = new LayoutAnimationController(animation, 0.12f); lac.setInterpolator(new DecelerateInterpolator()); return ll_container; }