package com.cola.ui;
import java.util.Calendar;
import java.util.TimeZone;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences.Editor;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.SimpleCursorAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
public class Frm_Addbills extends Activity implements OnClickListener {
EditText edittext_acctitem,EditTextDESC,Fee;
TextView mDate;
TextView mTime;
static final int RG_REQUEST = 0;
private int mYear;
private int mMonth;
private int mDay;
private int mHour;
private int mMinute;
Spinner s1;
Button BtnDate,BtnTime;
Button BtnCancel,BtnSave;
BilldbHelper billdb;
int acctitemid=-1;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setTitle("ColaBox-添加账单");
setContentView(R.layout.frm_addbills);
edittext_acctitem = (EditText)findViewById(R.id.edittext_acctitem);
edittext_acctitem.setOnClickListener(this);
EditTextDESC=(EditText)findViewById(R.id.EditTextDESC);
Fee=(EditText)findViewById(R.id.Fee);
BtnDate=(Button)findViewById(R.id.BtnDate);
BtnDate.setOnClickListener(this);
BtnTime=(Button)findViewById(R.id.BtnTime);
BtnTime.setOnClickListener(this);
BtnCancel=(Button)findViewById(R.id.BtnCancel);
BtnCancel.setOnClickListener(this);
BtnSave=(Button)findViewById(R.id.BtnSave);
BtnSave.setOnClickListener(this);
mDate = (TextView) findViewById(R.id.vdate);
mTime = (TextView) findViewById(R.id.vtime);
//Calendar c=Calendar.getInstance(Locale.CHINA);
initTime();
setDatetime();
billdb = new BilldbHelper(this);
s1=(Spinner) findViewById(R.id.Spinner01);
String[] from= new String[]{"caption"};
int[] to=new int[]{android.R.id.text1};
Cursor cur=billdb.getUserid();
SimpleCursorAdapter mAdapter=new SimpleCursorAdapter(this,android.R.layout.simple_spinner_item, cur,from, to);
mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(mAdapter);
//getBillsTotal
}
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, 1, 0, "账目明细").setIcon(R.drawable.editbills);
//menu.add(0, 2, 0, "账目统计").setIcon(R.drawable.editbills2);
//menu.add(0, 3, 0, "账目报表").setIcon(R.drawable.billsum1);
menu.add(0, 4, 0, "退 出").setIcon(R.drawable.quit);
menu.add(0, 5, 0, "关于ColaBox");
return true;
}
public void onClick(View v) {
if (v.equals(edittext_acctitem)) {
Log.v("ColaBox", "cmd=edittext_acctitem");
//test
Editor sharedata = getSharedPreferences("data", 0).edit();
sharedata.putString("item","hello getSharedPreferences");
sharedata.commit();
Intent intent = new Intent();
intent.setClass(Frm_Addbills.this, Frm_Editacctitem.class);
startActivityForResult(intent, RG_REQUEST);
} else if (v.equals(BtnTime)){
showDialog(1);
} else if (v.equals(BtnDate)){
showDialog(2);
} else if (v.equals(BtnCancel)){
cancel();
} else if (v.equals(BtnSave)){
save();
}
}
public boolean onOptionsItemSelected(MenuItem item) {
//Log.v("ColaBox", "getmenuitemid=" + item.getItemId());
switch (item.getItemId()) {
case 1:
Intent intent = new Intent();
//intent.setClass(Frm_Addbills.this, Grid_bills.class);
intent.setClassName(Frm_Addbills.this,"com.cola.ui.Grid_bills");;
startActivity(intent);
return true;
case 2:
int nOrientation = getRequestedOrientation();
if (nOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
else
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
return true;
case 3:
Intent i = new Intent();
i.setClass(Frm_Addbills.this, LocalService.class);
ComponentName compName = startService(i);
if (compName == null)
{
Log.e("main_Service", "startService() failed!");
}
//startService(new Intent(Frm_Addbills.this,mainService.class));
return true;
case 4:
QuitApp();
return true;
case 5:
new AlertDialog.Builder(this)
.setTitle("ColaBox")
.setMessage("作者:UntosiL Email:untosil@gmail.com Blog:blog.csdn.net/untosil")
.show();
return true;
}
return false;
}
public void QuitApp() {
new AlertDialog.Builder(Frm_Addbills.this).setTitle("提示").setMessage(
"确定退出?").setIcon(R.drawable.quit).setPositiveButton("确定",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
billdb.close();
finish();
}
}).setNegativeButton("取消",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}).show();
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RG_REQUEST) {
if (resultCode == RESULT_CANCELED) {
// setTitle("Canceled...");
} else if (resultCode == RESULT_OK) {
// setTitle((String)data.getCharSequenceExtra("DataKey"));
edittext_acctitem.setText((String) data.getCharSequenceExtra("name"));
acctitemid=Integer.parseInt((String)data.getCharSequenceExtra("id"));
Log.v("cola","get acctitemid="+acctitemid);
}
}
}
private void cancel(){
Log.v("cola","u put cancel btn");
edittext_acctitem.setText("");
Fee.setText("");
acctitemid=-1;
initTime();setDatetime();
EditTextDESC.setText("");
}
private void save(){
Log.v("cola","u put save btn");
if (acctitemid==-1){
new AlertDialog.Builder(this)
.setMessage("请首先选择账目.")
.show();
return;
}
int fee=0;
String s=Fee.getText().toString();
int pos=s.indexOf(".");
//Log.v("cola","i="+(s.length()-pos));
if (pos>0){
if (s.length()-pos<3){
s=s+"0";
}
fee=Integer.parseInt(s.substring(0,pos)+s.substring(pos+1,pos+3));
}else{
fee=Integer.parseInt(s)*100;
}
Log.v("cola","u put save btn");
if (billdb.Bills_save(acctitemid,fee,(int)s1.getSelectedItemId(), ((TextView)mDate).getText().toString(), ((TextView)mTime).getText().toString(),EditTextDESC.getText().toString())){
Toast.makeText(this, "保存成功.", Toast.LENGTH_SHORT).show();
cancel();
}else{
Toast.makeText(this, "保存失败,请检查数据.", Toast.LENGTH_SHORT).show();
}
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
QuitApp();
return true;
}
return false;
}
private void initTime(){
Calendar c = Calendar. getInstance(TimeZone.getTimeZone("GMT+08:00"));
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH)+1;
mDay = c.get(Calendar.DAY_OF_MONTH);
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
}
private void setDa
没有合适的资源?快使用搜索试试~ 我知道了~
小程序 个人记账软件.rar
共67个文件
class:29个
png:13个
xml:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 184 浏览量
2023-02-03
11:45:07
上传
评论
收藏 383KB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序 个人记账软件.rar (67个子文件)
1-1209161113430-L.png 53KB
1_120916111435_1.png 22KB
1_120916111435_2.png 62KB
1_120916111436_3.jpg 27KB
Android 个人记账软件
ColaBox
.classpath 280B
src
com
cola
ui
Dialog_edit.java 2KB
ColaBox.java 2KB
Frm_Editacctitem.java 7KB
Frm_Addbills.java 10KB
Grid_bills.java 5KB
BilldbHelper.java 8KB
LocalService.java 2KB
HorizontalSlider.java1 1KB
res
values
strings.xml 172B
layout
main.xml 688B
grid_items.xml 1KB
frm_editacctitem.xml 374B
msgbox.xml 382B
frm_addbills.xml 5KB
grid_bills.xml 3KB
drawable
edit.png 2KB
editbills.png 1KB
logo.png 15KB
logo2.png 4KB
logo3.png 16KB
billsum1.png 2KB
billsum2.png 2KB
quit.png 2KB
editbills2.png 1KB
icon.png 3KB
bin
resources.ap_ 56KB
classes.dex 32KB
ColaBox.apk 74KB
com
cola
ui
Frm_Addbills$3.class 938B
Frm_Addbills$2.class 918B
LocalService.class 1KB
ColaBox$2.class 834B
ColaBox.class 2KB
Dialog_edit.class 3KB
ColaBox$1.class 962B
Grid_bills$1.class 2KB
Frm_Editacctitem$2.class 1KB
Frm_Editacctitem.class 7KB
R$string.class 408B
R$layout.class 547B
Grid_bills$3.class 849B
Grid_bills.class 6KB
R$id.class 2KB
Frm_Editacctitem$1.class 1KB
Grid_bills$2.class 1KB
R$attr.class 319B
Frm_Editacctitem$MyExpandableListAdapter.class 2KB
BilldbHelper.class 8KB
Frm_Editacctitem$4.class 865B
R$drawable.class 652B
Frm_Addbills$1.class 978B
Dialog_edit$OnDateSetListener.class 257B
Frm_Addbills.class 11KB
LocalService$LocalBinder.class 583B
Frm_Editacctitem$3.class 1KB
Frm_Addbills$4.class 798B
R.class 482B
HorizontalSlider.java1 1KB
default.properties 364B
.project 843B
AndroidManifest.xml 960B
gen
com
cola
ui
R.java 3KB
共 67 条
- 1
资源评论
大富大贵7
- 粉丝: 389
- 资源: 8868
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功