Skip to content

Commit

Permalink
hzuapps#2 hzuapps#405 第二次实验
Browse files Browse the repository at this point in the history
  • Loading branch information
1814080911138 committed Nov 1, 2020
1 parent a76b5f8 commit ecf1b52
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 26 deletions.
12 changes: 6 additions & 6 deletions students/sec1814080911138/AboutActivity.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.example.pomelo_note;
package edu.hzuapps.androidlabs.examples;

import android.app.Activity;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class AboutActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState){
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about_view);
setContentView(R.layout.activity_about);
}


}
12 changes: 5 additions & 7 deletions students/sec1814080911138/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.pomelonote">
package="edu.hzuapps.androidlabs.examples">

<application
android:allowBackup="true"
Expand All @@ -10,11 +9,10 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".AddAcitivity"></activity>
<activity android:name=".CostBean" /></activity>
<activity android:name=".Sec1814080911138Activity"</activity>
<activity android:name=".HelpActivity"></activity>
<intent-filter>
<activity android:name=".ChartActivity"></activity>
<activity android:name=".AboutActivity" />
<activity android:name=".Sec1814080911138Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
Expand Down
50 changes: 50 additions & 0 deletions students/sec1814080911138/ChartActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package edu.hzuapps.androidlabs.examples;

/* 首先我们先往项目里添加一个画折线图需要的依赖包hellocharts-library-1.5.8.jar */
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import lecho.lib.hellocharts.model.Axis;
import lecho.lib.hellocharts.model.ChartData;
import lecho.lib.hellocharts.model.Line;
import lecho.lib.hellocharts.model.LineChartData;
import lecho.lib.hellocharts.model.PointValue;
import lecho.lib.hellocharts.model.ValueShape;
import lecho.lib.hellocharts.util.ChartUtils;
import lecho.lib.hellocharts.view.Chart;
import lecho.lib.hellocharts.view.LineChartView;
public class ChartActivity extends AppCompatActivity {

}
private LineChartView mChart;
private Map<String,Integer> table = new TreeMap<>(); //日期排序
private LineChartData mData = new LineChartData();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chart);
}
}
private void generateData(){ //设置折线图的线颜色等属性
List<Line> lines=new ArrayList<>();
List<PointValue> values=new ArrayList<>();
int indexX=0;
for(Integer value:table.values()){
values.add(new PointValue(indexX,value));
indexX++;
Line line = new Line(values);
line.setColor(ChartUtils.COLOR_GREEN);
line.setShape(ValueShape.CIRCLE);
line.setPointColor(ChartUtils.COLOR_ORANGE);
lines.add(line);
mData = new LineChartData(lines);
mData.setLines(lines);
mChart.setLineChartData(mData);
}
}
61 changes: 48 additions & 13 deletions students/sec1814080911138/Sec1814080911138Activity.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,54 @@
package com.example.pomelonote
package edu.hzuapps.androidlabs.examples;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import java.util.List;
import android.widget.Toast;
import android.widget.DatePicker;
importimport android.view.Menu; android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity{
public class Sec1814080911138Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
private List<CostBean> mCostBeanList;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sec1814080911138);
}
}
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
builder.setTitle("新建支出");//dialog的标题
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {

private List < CostBean > mCostBeanList;
mCostBeanList = new ArrayList<>();
ListView costList = (ListView) findViewById(R.id.lv_main);

public void onClick(DialogInterface dialog, int which) {//当点击确定时,
CostBean costBean = new CostBean();
costBean.costTitle = title.getText().toString();//将对应的属性输入
costBean.costMoney = money.getText().toString();
costBean.costDate = date.getYear() + "-" + (date.getMonth() + 1) + "-" +
date.getDayOfMonth();
costBean.costDate = date.getYear()+"-";

if(date.getMonth()+1<10)costBean.costDate+="0";
costBean.costDate+=(date.getMonth()+1)+"-";
if(date.getDayOfMonth()<10) costBean.costDate+="0";
costBean.costDate+=date.getDayOfMonth();


//当输入为空时提醒
if("".equals(costBean.costTitle) || "".equals(costBean.costMoney) || "".equals(costBean.costDate))
{
Toast.makeText(MainActivity.this,"信息不完整",Toast.LENGTH_SHORT).show();
return;
}
if(costBean.costMoney.length()>4)
{
Toast.makeText(MainActivity.this,"金额过大",Toast.LENGTH_SHORT).show();
return;
}
builder.setNegativeButton("取消", null);//取消时退出
builder.create().show();//显示dialog,即自定义的布局
}
});
}

}

0 comments on commit ecf1b52

Please sign in to comment.