Android:实现安卓小程序

阅读: 评论:0

Android:实现安卓小程序

Android:实现安卓小程序

private List list;

private String root_file;

public NoteManager(Context context){

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

this.mContext = context;

list = getNoteList();

}

//更新当前notes列表

public void updateNoteList(List now_data){

try {

File file = new File(root_file);

if (!ists()){

}

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 记事本的编辑


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

res/layout/l

&base.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”>

&base.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" />

&base.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" />

</base.floatingactionbutton.FloatingActionsMenu>

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

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

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

| — | — |

|

本文发布于:2024-02-04 19:53:14,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170715225859044.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:程序   Android   安卓小
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23