当前位置:   article > 正文

HarmonyOS开发——我的通讯录_鸿蒙 联系人管理

鸿蒙 联系人管理

概述:

        本次项目是我这个学期鸿蒙应用开发的结课作业。是根据平时所学内容以及自己手机上面的通讯录做出来的demo。

开发工具

        DevEco Studio

APP图标如下:

功能介绍:

        1. 具有显示联系人列表、添加联系人信息、删除联系人、修改联系人信息等功能;

        2.储存联系人信息时并未使用数据库,而是通过使用配置文件写入输入的数据,并进行读取或修改;

        3.还具有修改底部状态栏配色的功能。

实现功能的说明:

        1.在编辑时,只有输入姓名,才会出现确认按钮:实现这一操作,只需要检查姓名输入框中的内容是否为空,如果是空,则将该组件隐藏,如果不是空则将该组件设置为可见。

        2.实现底部配色主题得切换:将底部得配色归纳成四种Rgb配色,统一得存放在BottomBarColor.java文件中,使其保持static/final,并且编写相应得static函数操作。当用户选择了某个主题配色并点击“应用”按钮后,会调用设置相应得颜色,即可达到切换配色得目的。

项目文件结构图:

主要程序代码:

ability_main.xml:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <DirectionalLayout
  3. xmlns:ohos="http://schemas.huawei.com/res/ohos"
  4. ohos:id="$+id:main_rootdl"
  5. ohos:height="match_parent"
  6. ohos:width="match_parent"
  7. ohos:orientation="vertical"
  8. ohos:alignment="horizontal_center"
  9. ohos:background_element="$graphic:background_ability_main">
  10. <DirectionalLayout
  11. ohos:id="$+id:main_rootdl_ddl1"
  12. ohos:height="0"
  13. ohos:weight="0.6"
  14. ohos:width="match_parent"
  15. ohos:orientation="vertical"
  16. ohos:alignment="horizontal_center">
  17. </DirectionalLayout>
  18. <DirectionalLayout
  19. ohos:id="$+id:main_rootdl_ddl2"
  20. ohos:height="0"
  21. ohos:weight="8.8"
  22. ohos:width="match_parent"
  23. ohos:top_margin="5vp"
  24. ohos:background_element="$graphic:background_ddl2">
  25. </DirectionalLayout>
  26. <DirectionalLayout
  27. ohos:id="$+id:main_rootdl_ddl3"
  28. ohos:height="0"
  29. ohos:weight="0.6"
  30. ohos:width="match_parent"
  31. ohos:top_margin="5vp"
  32. ohos:bottom_margin="5vp"
  33. ohos:left_margin="45vp"
  34. ohos:right_margin="45vp"
  35. ohos:orientation="horizontal"
  36. ohos:alignment="vertical_center"
  37. ohos:background_element="$graphic:background_ddl3">
  38. <Button
  39. ohos:id="$+id:ddl3_butpeople"
  40. ohos:height="match_parent"
  41. ohos:width="0"
  42. ohos:weight="1"
  43. ohos:margin="3vp"
  44. ohos:text="$string:people"
  45. ohos:text_alignment="center"
  46. ohos:text_size="25vp"
  47. ohos:text_color="#FFB35353"
  48. ohos:background_element="$graphic:background_bottombutton">
  49. </Button>
  50. <Button
  51. ohos:id="$+id:ddl3_butedit"
  52. ohos:height="match_parent"
  53. ohos:width="0"
  54. ohos:weight="1"
  55. ohos:margin="3vp"
  56. ohos:text="$string:edit"
  57. ohos:text_alignment="center"
  58. ohos:text_size="25vp"
  59. ohos:text_color="#FF1086CA"
  60. ohos:background_element="$graphic:background_bottombutton">
  61. </Button>
  62. <Button
  63. ohos:id="$+id:ddl3_butconfig"
  64. ohos:height="match_parent"
  65. ohos:width="0"
  66. ohos:weight="1"
  67. ohos:margin="3vp"
  68. ohos:text="$string:config"
  69. ohos:text_alignment="center"
  70. ohos:text_size="25vp"
  71. ohos:text_color="#FF79086A"
  72. ohos:background_element="$graphic:background_bottombutton">
  73. </Button>
  74. </DirectionalLayout>
  75. </DirectionalLayout>

 ability_edit.xml:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <DirectionalLayout
  3. xmlns:ohos="http://schemas.huawei.com/res/ohos"
  4. ohos:id="$+id:edit_area_rootdl"
  5. ohos:height="match_parent"
  6. ohos:width="match_parent"
  7. ohos:orientation="vertical"
  8. ohos:alignment="horizontal_center">
  9. <DirectionalLayout
  10. ohos:id="$+id:edit_name_dlyt"
  11. ohos:height="60vp"
  12. ohos:width="match_parent"
  13. ohos:margin="10vp"
  14. ohos:orientation="horizontal"
  15. ohos:alignment="vertical_center">
  16. <Text
  17. ohos:id="$+id:edit_nametext"
  18. ohos:height="match_parent"
  19. ohos:width="0"
  20. ohos:weight="3"
  21. ohos:text="待输入"
  22. ohos:text_alignment="center"
  23. ohos:multiple_lines="true"
  24. ohos:auto_font_size="true"
  25. ohos:text_color="#FF6D37D2"
  26. ohos:background_element="$graphic:background_edit_addnametext">
  27. </Text>
  28. <TextField
  29. ohos:id="$+id:edit_nametfd"
  30. ohos:height="match_parent"
  31. ohos:width="0"
  32. ohos:weight="7"
  33. ohos:hint="姓名"
  34. ohos:text_alignment="center"
  35. ohos:text_size="20vp"
  36. ohos:hint_color="gray"
  37. ohos:background_element="$graphic:background_edit_addtfd">
  38. </TextField>
  39. </DirectionalLayout>
  40. <DirectionalLayout
  41. ohos:id="$+id:edit_tel_dlyt"
  42. ohos:height="40vp"
  43. ohos:width="match_parent"
  44. ohos:margin="5vp"
  45. ohos:orientation="horizontal"
  46. ohos:alignment="vertical_center">
  47. <Button
  48. ohos:id="$+id:edit_addtel_but"
  49. ohos:height="match_parent"
  50. ohos:width="40vp"
  51. ohos:text="+"
  52. ohos:text_alignment="center"
  53. ohos:text_size="20vp"
  54. ohos:text_color="green"
  55. ohos:background_element="$graphic:background_edit_addbutton">
  56. </Button>
  57. <TextField
  58. ohos:id="$+id:edit_teltfd"
  59. ohos:height="match_parent"
  60. ohos:width="match_parent"
  61. ohos:hint="电话"
  62. ohos:text_alignment="center"
  63. ohos:text_size="20vp"
  64. ohos:hint_color="gray"
  65. ohos:background_element="$graphic:background_edit_addtfd">
  66. </TextField>
  67. </DirectionalLayout>
  68. <DirectionalLayout
  69. ohos:id="$+id:edit_email_dlyt"
  70. ohos:height="40vp"
  71. ohos:width="match_parent"
  72. ohos:margin="5vp"
  73. ohos:orientation="horizontal"
  74. ohos:alignment="vertical_center">
  75. <Button
  76. ohos:id="$+id:edit_addemail_but"
  77. ohos:height="match_parent"
  78. ohos:width="40vp"
  79. ohos:text="+"
  80. ohos:text_alignment="center"
  81. ohos:text_size="20vp"
  82. ohos:text_color="green"
  83. ohos:background_element="$graphic:background_edit_addbutton">
  84. </Button>
  85. <TextField
  86. ohos:id="$+id:edit_emailtfd"
  87. ohos:height="match_parent"
  88. ohos:width="match_parent"
  89. ohos:hint="邮件"
  90. ohos:text_alignment="center"
  91. ohos:text_size="20vp"
  92. ohos:hint_color="gray"
  93. ohos:background_element="$graphic
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/308774
推荐阅读
相关标签
  

闽ICP备14008679号