您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 动画从屏幕下方弹出dialog
  所属分类: Android
  开发工具:
  文件大小: 1mb
  下载次数: 0
  上传时间: 2013-10-25
  提 供 者: u0113*****
 详细说明: 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; } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: animdialog
 输入关键字,在本站1000多万海量源码库中尽情搜索: