android studio大作业,android studio课程设计,记事本实现
先看效果图
功能点实现:
登录,注册,记事本分类添加,删除,数据分析统计报表,数据库使用SQLlite文章来源地址https://www.toymoban.com/news/detail-501741.html
部分实现代码
public class MainActivity extends BaseActivity {
private String titles[] = {"记账", "打卡", "便签"};
private int position = 0;
private ListView listview;
private ListAdapter mListAdapter;
private ContentDao mContentDao;
@Override
protected int getLayoutId() {
return R.layout.activity_main;
}
@Override
protected void initView() {
listview = findViewById(R.id.listview);
mListAdapter = new ListAdapter(MainActivity.this);
listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
ContentInfo contentInfo = mListAdapter.getItem(position);
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("确定要删除吗?");
builder.setMessage("删除后的数据将无法恢复");
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (mContentDao == null) {
mContentDao = new ContentDao(MainActivity.this);
}
int row = mContentDao.delete(contentInfo.get_id());
if (row > 0) {
if (null != mListAdapter) {
mListAdapter.setList(mContentDao.queryAll());
}
showToast("删除成功");
} else {
showToast("删除失败");
}
}
});
builder.show();
return true;
}
});
}
@Override
protected void setListener() {
findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("新建分类标签");
builder.setSingleChoiceItems(titles, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
position = which;
showToast(titles[which]);
}
});
builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (position == 0) {
startActivityForResult(new Intent(MainActivity.this, ChargeActivity.class), 200);
} else if (position == 1) {
startActivityForResult(new Intent(MainActivity.this, LocationActivity.class), 200);
} else {
startActivityForResult(new Intent(MainActivity.this, StickyActivity.class), 200);
}
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.show();
}
});
findViewById(R.id.chart).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, ChartActivity.class));
}
});
}
@Override
protected void initData() {
if (mContentDao == null) {
mContentDao = new ContentDao(this);
}
listview.setAdapter(mListAdapter);
mListAdapter.setList(mContentDao.queryAll());
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == 200) {
initData();
}
}
}
文章来源:https://www.toymoban.com/news/detail-501741.html
到了这里,关于android studio大作业,android studio课程设计,记事本实现的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!