动画从屏幕下方弹出dialog

时间:2016-11-14 05:15:56
【文件属性】:

文件名称:动画从屏幕下方弹出dialog

文件大小:1.17MB

文件格式:7Z

更新时间:2016-11-14 05:15:56

animdialog

package com.example.animdialogdemo; import com.example.calculatedemo.R; import android.app.Dialog; import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; public class CalculatorDialog extends Dialog implements OnClickListener { private Button[] btn = new Button[10]; private EditText etLed; private Button btnSub, btnPlus, btnEqual, btnDot, btnC, mButton_cancel, btnOk; private double predata = 0; private String preopt = "="; private boolean vbegin = true; private int i = 1; public CalculatorDialog(Context context) { super(context); // TODO Auto-generated constructor stub this.show(); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_caclu); findUiById(); addListener(); } private void findUiById() { etLed = (EditText) this.findViewById(R.id.ed_led); btn[0] = (Button) this.findViewById(R.id.mButton0); btn[1] = (Button) this.findViewById(R.id.mButton1); btn[2] = (Button) this.findViewById(R.id.mButton2); btn[3] = (Button) this.findViewById(R.id.mButton3); btn[4] = (Button) this.findViewById(R.id.mButton4); btn[5] = (Button) this.findViewById(R.id.mButton5); btn[6] = (Button) this.findViewById(R.id.mButton6); btn[7] = (Button) this.findViewById(R.id.mButton7); btn[8] = (Button) this.findViewById(R.id.mButton8); btn[9] = (Button) this.findViewById(R.id.mButton9); btnSub = (Button) this.findViewById(R.id.mButton_jia); btnPlus = (Button) this.findViewById(R.id.mButton_jian); btnEqual = (Button) this.findViewById(R.id.mButton_equ); btnDot = (Button) this.findViewById(R.id.mButton_dian); btnC = (Button) findViewById(R.id.mButton_C); btnOk = (Button) this.findViewById(R.id.mButton_ok); mButton_cancel = (Button) this.findViewById(R.id.mButton_cancel); } public void addListener() { for (int i = 0; i < btn.length; i++) { btn[i].setOnClickListener(this); } btnOk.setOnClickListener(this); btnSub.setOnClickListener(this); btnPlus.setOnClickListener(this); btnEqual.setOnClickListener(this); btnDot.setOnClickListener(this); btnC.setOnClickListener(this); mButton_cancel.setOnClickListener(this); } public void onClick(View v) { String command = ((Button) v).getText().toString(); String str = etLed.getText().toString(); if (command.compareTo("bac") == 0) { if (str.length() > 1) { etLed.setText(str.substring(0, str.length() - 1)); } else if (str.length() == 1) { etLed.setText("0"); vbegin = true; } } else if (command.compareTo("C") == 0) { etLed.setText("0"); vbegin = true; predata = 0; preopt = "="; } else if ("0123456789".indexOf(command) != -1) { wtNumber(command); } else if ("+-=".indexOf(command) != -1) { wtOperater(command); } if ("ȷ��".equals(command)) { this.dismiss(); } switch (v.getId()) { case R.id.mButton_cancel: dismiss(); break; default: break; } } private void wtNumber(String str) { if (vbegin) { etLed.setText(str); } else { etLed.append(str); } vbegin = false; } private void wtOperater(String opt) { try { double temp = Double.parseDouble(etLed.getText().toString()); if (vbegin) { preopt = opt; } else { if (preopt.equals("=")) { predata = temp; } else if (preopt.equals("+")) { predata += temp; } } etLed.setText(predata + ""); preopt = opt; } catch (NumberFormatException e) { etLed.setText("����Ϊ0"); } catch (ArithmeticException e) { etLed.setText("����Ϊ0"); preopt = "="; } finally { vbegin = true; } } }


【文件预览】:
AnimDialogDemos
----.project(851B)
----project.properties(563B)
----src()
--------com()
----AndroidManifest.xml(897B)
----res()
--------drawable-ldpi()
--------drawable-hdpi()
--------values-v11()
--------menu()
--------drawable-mdpi()
--------layout()
--------anim()
--------values-sw600dp()
--------drawable-xxhdpi()
--------drawable-xhdpi()
--------values()
--------values-sw720dp-land()
--------values-v14()
----.settings()
--------org.eclipse.jdt.core.prefs(177B)
--------org.eclipse.core.resources.prefs(102B)
----assets()
----gen()
--------com()
----libs()
--------android-support-v4.jar(543KB)
----.classpath(475B)
----proguard-project.txt(781B)
----ic_launcher-web.png(50KB)
----bin()
--------AnimDialogDemos.apk(263KB)
--------resources.ap_(49KB)
--------classes()
--------AndroidManifest.xml(897B)
--------dexedLibs()
--------res()
--------classes.dex(800KB)

网友评论

  • 不错,值得学习
  • 有值得学习的东西
  • 超实用,不过需要修改下才行
  • 效果很好,解决了我的项目问题,谢谢楼主分享!
  • iewgood 我的可以哦
  • 没看到弹出效果