Dialog_edit.java
public class Dialog_edit extends AlertDialog implements OnClickListener {
private String text = "";
private EditText edit;
private OnDateSetListener mCallback;
private LinearLayout layout;
public interface OnDateSetListener {
void onDateSet(String text);
}
protected Dialog_edit(Context context, String title, String value,
OnDateSetListener Callback) {
super(context);
mCallback = Callback;
TextView label = new TextView(context);
label.setText("hint");
edit = new EditText(context);
edit.setText(value);
layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams param2 = new LinearLayout.LayoutParams(200,
50);
layout.addView(edit, param2);
setView(layout);
setTitle(title);
setButton("确定", this);
setButton2("取消", (OnClickListener) null);
}
public void onClick(DialogInterface dialog, int which) {
text = edit.getText().toString();
Log.v("cola", "U click text=" + text);
if (mCallback != null)
mCallback.onDateSet(text);
}
}
ColaBox.java
public class ColaBox extends Activity {
private Handler mHandler = new Handler();
ImageView imageview;
TextView textview;
int alpha = 255;
int b = 0;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imageview = (ImageView) this.findViewById(R.id.ImageView01);
textview = (TextView) this.findViewById(R.id.TextView01);
Log.v("ColaBox", "ColaBox start ...");
imageview.setAlpha(alpha);
new Thread(new Runnable() {
public void run() {
initApp();
while (b < 2) {
try {
if (b == 0) {
Thread.sleep(1000);
b = 1;
} else {
Thread.sleep(50);
}
updateApp();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
imageview.setAlpha(alpha);
imageview.invalidate();
}
};
}
public void updateApp() {
alpha -= 5;
if (alpha <= 0) {
b = 2;
Intent in = new Intent(this, com.cola.ui.Frm_Addbills.class);
startActivity(in);
this.finish();
}
mHandler.sendMessage(mHandler.obtainMessage());
}
public void initApp(){
BilldbHelper billdb=new BilldbHelper(this);
billdb.FirstStart();
billdb.close();
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.v("cola", "keycode=" + keyCode);
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
Log.v("ColaBox", "ColaBox end ...");
return true;
}
return false;
}
}
Grid_bills.java
public class Grid_bills extends Activity implements OnItemLongClickListener {
BilldbHelper billdb;
View sv;
EditText edit;
AbsoluteLayout alayout;
int a = 10, b = 10;
GridView grd;
TextView total;
DatePicker dp;
Button okbtn;
ListView lv;
private int mYear;
private int mMonth;
private int mDay;
String today;
String[] from;
int[] to;
SimpleCursorAdapter mAdapter;
Cursor cur;
int _id;
protected GridView listHands = null;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.grid_bills);
billdb = new BilldbHelper(this);
lv = (ListView) findViewById(R.id.listview);
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);
today = mYear + "-" + mMonth;
setTitle("ColaBox-账单明细(" + today + ")");
cur = billdb.getBills(today);
from = new String[] { "rowid", "name", "fee", "sdate", "desc" };
to = new int[] { R.id.item1, R.id.item2, R.id.item3, R.id.item4,
R.id.item5 };
mAdapter = new SimpleCursorAdapter(this, R.layout.grid_items, cur,
from, to);
lv.setAdapter(mAdapter);
// getBillsTotal
total = (TextView) findViewById(R.id.totalitem);
total.setText(billdb.getBillsTotal(today));
lv.setOnItemLongClickListener(this);
}
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.editbills);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
// Log.v("ColaBox", "getmenuitemid=" + item.getItemId());
switch (item.getItemId()) {
case 1:
showDialog("请选择年月:", "");
return true;
case 2:
// Log.v("cola",lv.getSelectedItemId()+" p");
// OnItemLongClickListener onItemLongClick;
// lv.setOnItemLongClickListener(this);
return true;
}
return false;
}
private void showDialog(String title, String text) {
final DatePickerDialog dia = new DatePickerDialog(this,
mDateSetListener, mYear, mMonth-1, mDay);
dia.show();
}
private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
mYear = year;
mMonth = monthOfYear+1;
mDay = dayOfMonth;
today = mYear + "-" + mMonth;
setTitle("ColaBox-账单明细(" + today + ")");
cur = billdb.getBills(today);
mAdapter.changeCursor(cur);
//lv.setAdapter(mAdapter);
((SimpleCursorAdapter) mAdapter).notifyDataSetChanged();
}
};
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
// log.e("calllogactivity", view.tostring() + "position=" + position);
// charsequence number = ((textview) view).gettext();
// toast t = toast.maketext(this, number + " is long clicked",
// toast.length_long);
// t.show();
_id=(int)id;
new AlertDialog.Builder(this).setTitle("提示").setMessage(
<supports-screens android:largeScreens="true"/>
加入这句话可以根据手机屏幕调整布局
运行结果![](https://img-blog.csdn.net/20161229204901683?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbWNoYW9zOTg3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](https://img-blog.csdn.net/20161229204917183?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbWNoYW9zOTg3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](https://img-blog.csdn.net/20161229204930291?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbWNoYW9zOTg3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](https://img-blog.csdn.net/20161229204942369?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbWNoYW9zOTg3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](https://img-blog.csdn.net/20161229205041575?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbWNoYW9zOTg3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
提升空间
1.增加设置选项,增加账户可以共用一个账单。
2.优化软件界面,使界面应用更丰富,显示更具体。
3.本期账单仅供参考本月的账单,可以增加账单查询功能,可查询之前的账单。
4.提供更加丰富的内容,比如预支和透支,结余比较,。
2.优化软件界面,使界面应用更丰富,显示更具体。
3.本期账单仅供参考本月的账单,可以增加账单查询功能,可查询之前的账单。
4.提供更加丰富的内容,比如预支和透支,结余比较,。