程序使用到的界面文件定义在res/layout目录下,其中,main.xml文件定义MainActivity的界面,它的内容如下所示:

        
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. android:gravity="bottom">
  7. <ListView
  8. android:id="@+id/listview_article"
  9. android:layout_width="fill_parent"
  10. android:layout_height="wrap_content"
  11. android:layout_weight="1"
  12. android:background="@drawable/border"
  13. android:choiceMode="singleChoice">
  14. </ListView>
  15. <LinearLayout
  16. android:orientation="horizontal"
  17. android:layout_height="wrap_content"
  18. android:layout_width="match_parent"
  19. android:gravity="center"
  20. android:layout_marginTop="10dp">
  21. <Button
  22. android:id="@+id/button_add"
  23. android:layout_width="wrap_content"
  24. android:layout_height="wrap_content"
  25. android:paddingLeft="15dp"
  26. android:paddingRight="15dp"
  27. android:text="@string/add">
  28. </Button>
  29. </LinearLayout>
  30. </LinearLayout>
item.xml文件定义了ListView中每一个文章信息条目的显示界面,它的内容如下所示:
        
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <LinearLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:orientation="vertical"
  5. android:layout_width="fill_parent"
  6. android:layout_height="wrap_content">
  7. <TextView
  8. android:id="@+id/textview_article_title"
  9. android:layout_width="fill_parent"
  10. android:layout_height="wrap_content">
  11. </TextView>
  12. <TextView
  13. android:id="@+id/textview_article_abstract"
  14. android:layout_width="fill_parent"
  15. android:layout_height="wrap_content">
  16. </TextView>
  17. <TextView
  18. android:id="@+id/textview_article_url"
  19. android:layout_width="fill_parent"
  20. android:layout_height="wrap_content"
  21. android:layout_marginBottom="10dp">
  22. </TextView>
  23. </LinearLayout>
article.xml文件定义了ArticleActivity的界面,它的内容如下所示:
        
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. android:gravity="center">
  7. <LinearLayout
  8. android:orientation="horizontal"
  9. android:layout_height="wrap_content"
  10. android:layout_width="fill_parent">
  11. <TextView
  12. android:layout_width="wrap_content"
  13. android:layout_height="wrap_content"
  14. android:layout_marginRight="24dp"
  15. android:text="@string/title">
  16. </TextView>
  17. <EditText
  18. android:id="@+id/edit_article_title"
  19. android:layout_width="fill_parent"
  20. android:layout_height="wrap_content">
  21. </EditText>
  22. </LinearLayout>
  23. <LinearLayout
  24. android:orientation="horizontal"
  25. android:layout_height="wrap_content"
  26. android:layout_width="fill_parent">
  27. <TextView
  28. android:layout_width="wrap_content"
  29. android:layout_height="wrap_content"
  30. android:text="@string/abs">
  31. </TextView>
  32. <EditText
  33. android:id="@+id/edit_article_abstract"
  34. android:layout_width="fill_parent"
  35. android:layout_height="wrap_content">
  36. </EditText>
  37. </LinearLayout>
  38. <LinearLayout
  39. android:orientation="horizontal"
  40. android:layout_height="wrap_content"
  41. android:layout_width="fill_parent">
  42. <TextView
  43. android:layout_width="wrap_content"
  44. android:layout_height="wrap_content"
  45. android:layout_marginRight="27dp"
  46. android:text="@string/url">
  47. </TextView>
  48. <EditText
  49. android:id="@+id/edit_article_url"
  50. android:layout_width="fill_parent"
  51. android:layout_height="wrap_content">
  52. </EditText>
  53. </LinearLayout>
  54. <LinearLayout
  55. android:orientation="horizontal"
  56. android:layout_height="wrap_content"
  57. android:layout_width="match_parent"
  58. android:gravity="center"
  59. android:layout_marginTop="10dp">
  60. <Button
  61. android:id="@+id/button_modify"
  62. android:layout_width="wrap_content"
  63. android:layout_height="wrap_content"
  64. android:text="@string/modify">
  65. </Button>
  66. <Button
  67. android:id="@+id/button_delete"
  68. android:layout_width="wrap_content"
  69. android:layout_height="wrap_content"
  70. android:text="@string/delete">
  71. </Button>
  72. <Button
  73. android:id="@+id/button_add_article"
  74. android:layout_width="wrap_content"
  75. android:layout_height="wrap_content"
  76. android:paddingLeft="16dp"
  77. android:paddingRight="16dp"
  78. android:text="@string/add">
  79. </Button>
  80. <Button
  81. android:id="@+id/button_cancel"
  82. android:layout_width="wrap_content"
  83. android:layout_height="wrap_content"
  84. android:text="@string/cancel">
  85. </Button>
  86. </LinearLayout>
  87. </LinearLayout>
在res/drawable目录下,有一个border.xml文件定义了MainActivity界面上的ListView的背景,它的内容如下所示:
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <shapexmlns:android="http://schemas.android.com/apk/res/android"
  3. android:shape="rectangle">
  4. <solidandroid:color="#ff0000ff"/>
  5. <strokeandroid:width="1dp"
  6. android:color="#000000">
  7. </stroke>
  8. <paddingandroid:left="7dp"
  9. android:top="7dp"
  10. android:right="7dp"
  11. android:bottom="7dp">
  12. </padding>
  13. <cornersandroid:radius="10dp"/>
  14. </shape>
程序使用到的字符串资源文件定义在res/values/strings.xml文件中,它的内容如下所示:
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <resources>
  3. <stringname="app_name">Article</string>
  4. <stringname="article">Article</string>
  5. <stringname="add">Add</string>
  6. <stringname="modify">Modify</string>
  7. <stringname="delete">Delete</string>
  8. <stringname="title">Title:</string>
  9. <stringname="abs">Abstract:</string>
  10. <stringname="url">URL:</string>
  11. <stringname="ok">OK</string>
  12. <stringname="cancel">Cancel</string>
  13. </resources>

更多相关文章

  1. android 手机虚拟按键 震动过程的追溯(1)
  2. Ubuntu 编译Android若干错误及解决方法
  3. android 打开电子市场中应用的界面
  4. 移植TM**到Android(安卓)| 编译
  5. Android(安卓)7.0 FileUriExposedException 的处理
  6. Android(安卓)由图片资源ID获取图片的文件名
  7. Android(安卓)内核编绎错误解决方案
  8. android中禁止GridView上下滑动的方法
  9. 将Android(安卓)SQLite db 文件转化成xml保存在xml

随机推荐

  1. 关于android studio报错transformClasses
  2. Android studio Caused by: org.gradle.a
  3. AndroidManifest.xml配置文件选项详解
  4. 【stagefrightplayer】1 调用过程
  5. ubuntu10.10下的android源码下载及编译
  6. Android与php服务器交互实例
  7. Android Activity实现切换动画的两种方法
  8. 在Android 的Camera 预览上执行 Drawing
  9. android发送json并解析返回json
  10. android Dialog中SeekBar的使用方法