Android:实现安卓小程序-记事本(备忘录)的开发,android原生开发前景

本文详述了如何使用Android原生开发实现一个记事本应用,包括数据存储、主界面设计、浮动菜单、编辑模式以及背景色设置等功能。通过自定义适配器展示Note条目,并实现背景色更改和闹钟功能,提供了丰富的用户体验。
摘要由CSDN通过智能技术生成

private List list;

private String root_file;

public NoteManager(Context context){

root_file = Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+“NoteList”;

this.mContext = context;

list = getNoteList();

}

//更新当前notes列表

public void updateNoteList(List now_data){

try {

File file = new File(root_file);

if (!file.exists()){

file.createNewFile();

}

ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(root_file));

oos.writeObject(now_data);

oos.close();

}

catch (Exception e1){

e1.printStackTrace();

}

}

}

3.3 主界面的设计


为了更好的用户体验,决定将用户设计设计成两种情况,一种为用户程序中暂无存储记事文件的情况下,一种为程序中已存有记事文件下。附上部分关键代码以及程序截图。

| 主界面-1 | 主界面-2 |

| — | — |

| 在这里插入图片描述 | 在这里插入图片描述 |

//检查数据列表是否为空,如果为空,那么渲染blank_View

public void emptyListCheck(){

int number = 0;

if(data!=null){

number=data.size();

}

if(number == 0) {

smlvMain.setVisibility(View.GONE);

RelativeLayout empty = (RelativeLayout) findViewById(R.id.blank_view);

empty.setVisibility(View.VISIBLE);

fabMenu.setVisibility(View.VISIBLE);

}else{

smlvMain.setVisibility(View.VISIBLE);

RelativeLayout empty = (RelativeLayout) findViewById(R.id.blank_view);

empty.setVisibility(View.GONE);

}

}

这里设置了Note条目的菜单模块和空白模块,若数据列表为空,则隐藏条目菜单模块,显示空白模块,若不为空,则隐藏空白模块,显示菜单模块。

3.4 记事本的编辑


可以看到在主界面的右下角存在一个浮动窗口菜单,这里涉及到第三方依赖的添加:

com.getbase.floatingactionbutton.FloatingActionButton

res/layout/activity_main.xml

<com.getbase.floatingactionbutton.FloatingActionsMenu

adroid:id="@+id/fab_menu"

adroid:layout_width=“wrap_content”

adroid:layout_height=“wrap_content”

adroid:layout_alignParentRight=“true”

adroid:layout_alignParentBottom=“true”

fab:fab_labelStyle="@style/fab_label_style"

app:fab_addButtonSize=“mini”

fab:fab_addButtonColorNormal="#5e96b9"

fab:fab_addButtonColorPressed="@null"

fab:fab_addButtonPlusIconColor="@color/black"

adroid:layout_marginBottom=“16dp”

adroid:layout_marginRight=“16dp”>

<com.getbase.floatingactionbutton.FloatingActionButton

adroid:id="@+id/fab_add"

adroid:layout_width=“wrap_content”

adroid:layout_height=“wrap_content”

fab:fab_colorNormal="@color/white"

fab:fab_colorPressed="@color/green"

fab:fab_title=“新备忘录”

fab:fab_size=“mini”

fab:fab_icon="@drawable/fab_add" />

<com.getbase.floatingactionbutton.FloatingActionButton

adroid:id="@+id/fab_exit"

adroid:layout_width=“wrap_content”

adroid:layout_height=“wrap_content”

fab:fab_colorNormal="@color/white"

fab:fab_colorPressed="@color/green"

fab:fab_title=“退出应用”

fab:fab_size=“mini”

app:fab_icon="@drawable/fab_exit" />

</com.getbase.floatingactionbutton.FloatingActionsMenu>

这里可以看到对浮动菜单栏的xml设计,包含两种功能,新建Note和应用的退出,涉及到功能的逻辑代码这里就不赘述了。

新建Note后,可在主界面-2下的点击Note条目或左滑条目进入编辑模式。

| 编辑模式-1 | 编辑模式-2 |

| — | — |

|

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值