-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #985 from linyuehuan24/master
#295 实验4~9修改后
- Loading branch information
Showing
7 changed files
with
774 additions
and
14 deletions.
There are no files selected for viewing
16 changes: 15 additions & 1 deletion
16
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901225/city.html
Large diffs are not rendered by default.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...ava/edu/hzuapps/androidworks/homeworks/net1314080903124/Net1314080903124MainActivity.java
This file was deleted.
Oops, something went wrong.
186 changes: 186 additions & 0 deletions
186
...n/java/edu/hzuapps/androidworks/homeworks/net1314080903124/Net1314080903124_AddEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
package edu.hzuapps.androidworks.homeworks.net1314080903124; | ||
/**************** | ||
* Author:Zachary(F.SB) | ||
* | ||
* | ||
* ********************/ | ||
import java.util.ArrayList; | ||
import java.util.Calendar; | ||
|
||
import models.TradeClass; | ||
import models.consumeClass; | ||
|
||
import android.app.Activity; | ||
import android.app.AlertDialog; | ||
import android.app.DatePickerDialog; | ||
import android.app.DatePickerDialog.OnDateSetListener; | ||
import android.app.Dialog; | ||
import android.content.DialogInterface; | ||
import android.os.Bundle; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
import android.view.View.OnTouchListener; | ||
import android.widget.AdapterView; | ||
import android.widget.AdapterView.OnItemSelectedListener; | ||
import edu.hzuapps.androidworks.homeworks.net1314080903124.R; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.Button; | ||
import android.widget.DatePicker; | ||
import android.widget.EditText; | ||
import android.widget.Spinner; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
public class Net1314080903124_AddEvent extends Activity{ | ||
private TextView addDate = null; | ||
private Spinner typeSpinner; | ||
public String addType=""; | ||
private Button addButton; | ||
private EditText money; | ||
DatePickerDialog.OnDateSetListener OnDateSetListener ; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.net1314080903124_addevent); | ||
|
||
this.typeSpinner = ((Spinner)findViewById(R.id.type)); | ||
ArrayList localArrayList = new ArrayList(); | ||
localArrayList.add("日常购物"); | ||
localArrayList.add("交际送礼"); | ||
localArrayList.add("餐饮开销"); | ||
localArrayList.add("购置衣物"); | ||
localArrayList.add("娱乐开销"); | ||
localArrayList.add("网费话费"); | ||
localArrayList.add("交通出行"); | ||
localArrayList.add("水电煤气"); | ||
localArrayList.add("其他花费"); | ||
ArrayAdapter localArrayAdapter = new ArrayAdapter(this, R.layout.net1314080903124_spinner_item, R.id.spinnerItem, localArrayList); | ||
this.typeSpinner.setAdapter(localArrayAdapter); | ||
this.typeSpinner.setPrompt("请选择消费类型"); | ||
this.typeSpinner.setOnItemSelectedListener(new SpinnerSelected()); | ||
this.addDate = ((TextView)findViewById(R.id.addDate)); | ||
this.addDate.setOnClickListener(new DateOnClick()); | ||
this.addButton = ((Button)findViewById(R.id.addButton)); | ||
this.addButton.setOnClickListener(new AddPocketClick()); | ||
this.money = ((EditText)findViewById(R.id.money)); | ||
|
||
OnDateSetListener = new DatePickerDialog.OnDateSetListener() | ||
{ | ||
public void onDateSet(DatePicker paramDatePicker, int paramInt1, int paramInt2, int paramInt3) | ||
{ | ||
Net1314080903124_AddEvent.this.addDate.setText(paramInt1 + "-" + (paramInt2 + 1) + "-" + paramInt3); | ||
} | ||
}; | ||
/* | ||
this.addDate=(TextView)findViewById(R.id.addDate); | ||
addDate.setOnTouchListener(new OnTouchListener(){ | ||
@Override | ||
public boolean onTouch(View arg0, MotionEvent arg1) { | ||
// TODO Auto-generated method stub | ||
Toast.makeText(Net1314080903124_AddEvent.this, "This is a Test!", Toast.LENGTH_LONG).show(); | ||
return false; | ||
} | ||
});*/ | ||
|
||
} | ||
protected Dialog onCreateDialog(int paramInt) | ||
{ | ||
Calendar localCalendar = Calendar.getInstance(); | ||
int i = localCalendar.get(Calendar.YEAR); | ||
int j = localCalendar.get(Calendar.MONTH); | ||
int k = localCalendar.get(Calendar.DAY_OF_MONTH); | ||
switch (paramInt) | ||
{ | ||
default: | ||
return null; | ||
case 1: | ||
} | ||
return new DatePickerDialog(this, this.OnDateSetListener, i, j, k); | ||
} | ||
|
||
//弹出提示 | ||
private void dialog() | ||
{ | ||
new AlertDialog.Builder(this).setTitle("添加一笔新消费?").setMessage("消费类型:" + this.addType + "\n消费金额:" + this.money.getText().toString() + "\n消费日期:" + this.addDate.getText().toString()).setPositiveButton("确定", new DialogInterface.OnClickListener() | ||
{ | ||
public void onClick(DialogInterface paramDialogInterface, int paramInt) | ||
{ | ||
Net1314080903124_AddEvent.this.setResult(-1); | ||
//Net1314080903124_AddEvent.this.addPocket(); | ||
//确定添加 | ||
consumeClass trade=new consumeClass(0, Float.parseFloat("-"+Net1314080903124_AddEvent.this.money.getText().toString()), Net1314080903124_AddEvent.this.addDate.getText().toString(), "123", addType, Net1314080903124_AddEvent.this); | ||
|
||
trade.trade_add(); | ||
Toast.makeText(Net1314080903124_AddEvent.this, "添加完成", 0).show(); | ||
} | ||
}).setNegativeButton("取消", new DialogInterface.OnClickListener() | ||
{ | ||
public void onClick(DialogInterface paramDialogInterface, int paramInt) | ||
{ | ||
} | ||
}).show(); | ||
} | ||
|
||
|
||
class AddPocketClick implements View.OnClickListener | ||
{ | ||
AddPocketClick() | ||
{ | ||
} | ||
|
||
public void onClick(View paramView) | ||
{ | ||
if (Net1314080903124_AddEvent.this.addDate.getText().equals("点击选择日期")) | ||
{ | ||
Toast.makeText(Net1314080903124_AddEvent.this, "请先选择消费日期", 0).show(); | ||
return; | ||
} | ||
if (Net1314080903124_AddEvent.this.money.getText().toString().trim().length() == 0) | ||
{ | ||
Toast.makeText(Net1314080903124_AddEvent.this, "请先填写消费金额", 0).show(); | ||
return; | ||
} | ||
Net1314080903124_AddEvent.this.dialog(); | ||
} | ||
} | ||
|
||
class DateOnClick implements View.OnClickListener | ||
{ | ||
DateOnClick() | ||
{ | ||
|
||
} | ||
|
||
public void onClick(View paramView) | ||
{ | ||
Net1314080903124_AddEvent.this.showDialog(1); | ||
} | ||
} | ||
|
||
|
||
class SpinnerSelected implements OnItemSelectedListener | ||
{ | ||
SpinnerSelected() | ||
{ | ||
} | ||
|
||
@Override | ||
public void onItemSelected(AdapterView<?> paramAdapterView, View arg1, int paramInt, | ||
long arg3) { | ||
// TODO Auto-generated method stub | ||
String str = paramAdapterView.getItemAtPosition(paramInt).toString(); | ||
Net1314080903124_AddEvent.this.addType = str; | ||
} | ||
|
||
@Override | ||
public void onNothingSelected(AdapterView<?> arg0) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
} | ||
} | ||
|
||
|
||
|
127 changes: 127 additions & 0 deletions
127
...zuapps/androidworks/homeworks/net1314080903124/Net1314080903124_QueryByMouthActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package edu.hzuapps.androidworks.homeworks.net1314080903124; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.widget.ListView; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Calendar; | ||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import models.MyPackage; | ||
import models.TradeClass; | ||
import models.consumeClass; | ||
|
||
public class Net1314080903124_QueryByMouthActivity extends Activity | ||
{ | ||
String[] bill_array=null; | ||
private ListView listView; | ||
private Map<Integer, Boolean> localmap; | ||
private Adapter_LS myadapter; | ||
private TextView textView; | ||
private void fillList() | ||
{ | ||
// TODO Auto-generated method stub | ||
//ArrayAdapter<String> adapter=null; | ||
listView =(ListView)findViewById(R.id.listViewlisi); | ||
textView =(TextView)findViewById(R.id.textViewlisi); | ||
|
||
Calendar localCalendar = Calendar.getInstance(); | ||
int year = localCalendar.get(Calendar.YEAR); | ||
int month = localCalendar.get(Calendar.MONTH)+1; | ||
String str1=new String(year+"-"+month); | ||
String str; | ||
List<Map<String, Object>> list=new ArrayList<Map<String, Object>>(); | ||
float todaymenoy=0; | ||
MyPackage pack=new MyPackage(this); | ||
List<TradeClass> List=pack.getAlltrade(); | ||
for(TradeClass con:List){ | ||
str = con.gettime(); | ||
str=str.substring(0, str.lastIndexOf('-')); | ||
if(str1.equals(str)){ | ||
todaymenoy+=con.getMoney(); | ||
Map<String,Object> map=new HashMap<String,Object>(); | ||
map.put("_id", con.getId()); | ||
map.put("money", ""+con.getMoney()); | ||
if(con.getPocketType().equals("日常购物")){ | ||
map.put("icon",R.drawable.richanggouwu); | ||
}else if(con.getPocketType().equals("交际送礼")){ | ||
map.put("icon",R.drawable.jiaojisongli); | ||
}else if(con.getPocketType().equals("餐饮开销")){ | ||
map.put("icon",R.drawable.canyingkaixiao); | ||
}else if(con.getPocketType().equals("购置衣物")){ | ||
map.put("icon",R.drawable.gouziyiwu); | ||
}else if(con.getPocketType().equals("娱乐开销")){ | ||
map.put("icon",R.drawable.yulekaixiao); | ||
}else if(con.getPocketType().equals("水电煤气")){ | ||
map.put("icon",R.drawable.shuidianmeiqi); | ||
}else if(con.getPocketType().equals("网费话费")){ | ||
map.put("icon",R.drawable.wannluohuafei); | ||
}else if(con.getPocketType().equals("交通出行")){ | ||
map.put("icon",R.drawable.jiaotongchuxing); | ||
}else if(con.getPocketType().equals("其他花费")){ | ||
map.put("icon",R.drawable.qita); | ||
}else{ | ||
map.put("icon",R.drawable.qita); | ||
} | ||
map.put("time", con.gettime()); | ||
map.put("type", con.getPocketType()); | ||
list.add(map); | ||
} | ||
} | ||
localmap = new HashMap<Integer, Boolean>(); | ||
myadapter=new Adapter_LS(this, list, localmap); | ||
textView.setText("本月共花费:"+(-todaymenoy)+"元"); | ||
listView.setAdapter(myadapter); | ||
} | ||
|
||
public void onCreate(Bundle paramBundle) | ||
{ | ||
super.onCreate(paramBundle); | ||
setContentView(R.layout.net1314080903124_all_bill); | ||
fillList(); | ||
} | ||
|
||
public boolean onCreateOptionsMenu(Menu paramMenu) | ||
{ | ||
paramMenu.add(0, 1, 1, "删除").setIcon(R.drawable.delete); | ||
return super.onCreateOptionsMenu(paramMenu); | ||
} | ||
|
||
public boolean onOptionsItemSelected(MenuItem paramMenuItem){ | ||
// = Adapter_TD.isSelected; | ||
Toast.makeText(this, "不能做假账哦!", 0).show(); | ||
/* | ||
if (localmap.size() <= 0) | ||
{ | ||
Toast.makeText(this, "请先选择要删除的消费记录!", 0).show(); | ||
return true; | ||
} | ||
consumeClass trade=new consumeClass(0, 0, "", "123", "", Net1314080903124_QueryByMouthActivity.this); | ||
Iterator<?> it = localmap.entrySet().iterator(); | ||
while (it.hasNext()) { | ||
Map.Entry entry = (Map.Entry) it.next(); | ||
Object key = entry.getKey(); | ||
Object value = entry.getValue(); | ||
if((Boolean)value){ | ||
trade.trade_delect((Integer)key); | ||
} | ||
//Log.i("nihao","key=" + key + " value=" + value); | ||
} | ||
fillList(); */ | ||
return true; | ||
} | ||
|
||
protected void onResume() | ||
{ | ||
fillList(); | ||
super.onResume(); | ||
} | ||
} |
Oops, something went wrong.