毕业设计- 基于Android的图片文字记事本
时间:2022-03-09 07:23:50 阅读数:30,814人阅读
作者:Android学习小站
版权声明:转载请注明出处,谢谢!
—— 忍者要冷静沉着,自己判断!打破忍者世界规则跟铁律的人,我们都叫他废物。可是,不懂得重视同伴的人,是最差劲的废物!
项目介绍
本记事本(备忘录)支持添加文字、图片、拍照、手绘等类型内容,记事本(备忘录)支持设置密码,支持设置闹钟提醒,可根据记事本(备忘录)内容搜索,也可根据创建时间查询记事本(备忘录);
项目截图
实现原理
布局文件activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#f1f1f1" android:orientation="vertical"> <com.anxiaobang.notes.view.AbScrollView android:id="@+id/absclv" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/rl_title" android:focusable="true" android:focusableInTouchMode="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"> <com.anxiaobang.notes.view.MyGridView android:id="@+id/lv_notes" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:horizontalSpacing="10dp" android:numColumns="2" android:verticalSpacing="10dp" /> </LinearLayout> </com.anxiaobang.notes.view.AbScrollView> <RelativeLayout android:id="@+id/rl_title" android:layout_width="match_parent" android:layout_height="50dp" android:layout_alignParentTop="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="horizontal"> <LinearLayout android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="1" android:layout_marginLeft="6dp" android:layout_marginTop="6dp" android:layout_marginBottom="6dp" android:background="@drawable/bg_b_colorprimary_j_6_stroke" android:gravity="center" android:orientation="horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="12dp" android:background="@drawable/title_edittext_search" /> <EditText android:id="@+id/et_keyword" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_vertical" android:layout_weight="1" android:background="@null" android:hint="请输入搜索关键字" android:imeOptions="actionSearch" android:paddingLeft="5dp" android:paddingRight="5dp" android:singleLine="true" android:textColorHint="#999999" android:textSize="14sp" /> </LinearLayout> <TextView android:id="@+id/title_right_tv" android:layout_width="60dp" android:layout_height="match_parent" android:gravity="center" android:onClick="onSearch" android:text="搜索" android:textColor="@color/colorPrimary" android:textSize="16sp" /> <TextView android:id="@+id/iv_icon" android:layout_width="60dp" android:layout_height="match_parent" android:gravity="center" android:onClick="onData" android:text="查询" android:textColor="@color/colorPrimary" android:textSize="16sp" /> </LinearLayout> </RelativeLayout> <LinearLayout android:id="@+id/rl" android:layout_width="120dp" android:layout_height="wrap_content" android:paddingTop="2dp" android:paddingBottom="4dp" android:layout_marginBottom="20dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:background="@drawable/bg_b_white_j_100" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="30dp" android:layout_height="30dp" android:background="@drawable/add1" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="新建" android:layout_marginTop="-4dp" android:textSize="13sp" android:textColor="#999999" /> </LinearLayout> </RelativeLayout>
/** * APP主页面 */ public class MainActivity extends Activity { // 添加按钮 private LinearLayout rl; // 数据库对象 private SQLiteDatabase db; // 自定义数据库类 private DatabaseOperation dop; // 消息列表 private MyGridView lv_notes; private TextView tv_note_id, tv_locktype, tv_lock; // 音乐播放器 public static MediaPlayer mediaPlayer; // 手机震动器 public static Vibrator vibrator; // 消息管理者 public AlarmManager am; // 搜索框 public EditText et_keyword; public MainAdapter adapter; private List<SQLBean> list; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (am == null) { am = (AlarmManager) getSystemService(ALARM_SERVICE); } try { Intent intent = new Intent(MainActivity.this, CallAlarm.class); PendingIntent sender = PendingIntent.getBroadcast( MainActivity.this, 0, intent, 0); am.setRepeating(AlarmManager.RTC_WAKEUP, 0, 60 * 1000, sender); } catch (Exception e) { e.printStackTrace(); } // 安卓6以上动态申请权限 if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); } } // 显示记事列表 private void showNotesList() { // 创建或打开数据库 获取数据 dop.create_db(); //获取数据库内容 Cursor cursor = dop.query_db(); list.clear(); if (cursor.getCount() > 0) { // 光标移动成功 while (cursor.moveToNext()) { // 把数据取出 SQLBean bean = new SQLBean();//创建数据库实体类 //保存日记信息id到实体类 bean.set_id("" + cursor.getInt(cursor.getColumnIndex("_id"))); bean.setContext(cursor.getString(cursor .getColumnIndex("context")));//保存日记内容到实体类 //保存日记标题到实体类 bean.setTitle(cursor.getString(cursor.getColumnIndex("title"))); //保存日记记录时间到实体类 bean.setTime(cursor.getString(cursor.getColumnIndex("time"))); bean.setDatatype(cursor.getString(cursor .getColumnIndex("datatype")));//保存日记是否设置提醒时间到实体类 bean.setDatatime(cursor.getString(cursor .getColumnIndex("datatime")));//保存日记提醒时间到实体类 bean.setLocktype(cursor.getString(cursor .getColumnIndex("locktype")));//保存日记是否设置了日记锁到实体类 //保存日记锁秘密到实体类 bean.setLock(cursor.getString(cursor.getColumnIndex("lock"))); list.add(bean);//把保存日记信息实体类保存到日记信息集合里 } //倒序显示数据 Collections.reverse(list); } dop.close_db();//关闭数据库 adapter.notifyDataSetChanged(); } // 记事列表长按监听器 class ItemLongClickEvent implements OnItemLongClickListener { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { //初始化日记id保存控件 tv_note_id = (TextView) view.findViewById(R.id.tv_note_id); //初始化是否添加日记锁保存控件 tv_locktype = (TextView) view.findViewById(R.id.tv_locktype); //初始化日记锁秘密保存信息 tv_lock = (TextView) view.findViewById(R.id.tv_lock); //获取控件上是否设置日记锁信息 String locktype = tv_locktype.getText().toString(); //获取控件上日记密码信息 String lock = tv_lock.getText().toString(); //获取控件上id信息转换成int类型 int item_id = Integer.parseInt(tv_note_id.getText().toString()); //弹出选择操作框方法 simpleList(item_id, locktype, lock); return true; } } // 简单列表对话框,用于选择操作 public void simpleList(final int item_id, final String locktype, final String lock) { //实例化AlertDialog AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, R.style.custom_dialog); //设置弹窗标题 alertDialogBuilder.setTitle("选择操作"); //设置弹窗选项内容 alertDialogBuilder.setItems(R.array.itemOperation, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { // 编辑 case 0: if ("0".equals(locktype)) else break; // 删除 case 1: if ("0".equals(locktype)) else break; } } }); alertDialogBuilder.create();//创造弹窗 alertDialogBuilder.show();//显示弹窗 } // 加密日记打开弹出的输入密码框 public void inputTitleDialog(final String lock, final int idtype, final int item_id) else { if (inputName.equals(lock)) { if (0 == idtype) { Intent intent = new Intent(MainActivity.this, AddActivity.class); intent.putExtra("editModel", "update"); intent.putExtra("noteId", item_id); startActivity(intent); } else if (1 == idtype) { dop.create_db(); dop.delete_db(item_id); dop.close_db(); // 刷新列表显示 lv_notes.invalidate(); showNotesList(); } } else { Toast.makeText(MainActivity.this, "密码不正确!", Toast.LENGTH_LONG).show(); } } } }); builder.show(); } // 搜索功能 public void onSearch(View v) { //获取搜索关键词 String ek = et_keyword.getText().toString(); if ("".equals(ek)) else } }
购买套餐
权益 | 套餐A | 套餐B |
---|---|---|
完整代码 | ![]() |
![]() |
远程调试 | 不支持 | ![]() |
代码答疑 | 不支持 | ![]() |
价 格 | ¥180 | ¥330 |
------转载请注明出处,感谢您对原创作者的支持------
有偿提供技术支持、Bug修复、项目外包、毕业设计、大小作业
Android学习小站
Q Q:1095817610
微信:jx-helu
邮箱:1095817610@qq.com
添加请备注"Android学习小站"
