Android应用程序组件Content Provider应用实例(4)
16lz
2021-01-24
程序使用到的界面文件定义在res/layout目录下,其中,main.xml文件定义MainActivity的界面,它的内容如下所示:
item.xml文件定义了ListView中每一个文章信息条目的显示界面,它的内容如下所示:
- <?xmlversion="1.0"encoding="utf-8"?>
- <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:gravity="bottom">
- <ListView
- android:id="@+id/listview_article"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:background="@drawable/border"
- android:choiceMode="singleChoice">
- </ListView>
- <LinearLayout
- android:orientation="horizontal"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:gravity="center"
- android:layout_marginTop="10dp">
- <Button
- android:id="@+id/button_add"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="15dp"
- android:paddingRight="15dp"
- android:text="@string/add">
- </Button>
- </LinearLayout>
- </LinearLayout>
article.xml文件定义了ArticleActivity的界面,它的内容如下所示:
- <?xmlversion="1.0"encoding="utf-8"?>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <TextView
- android:id="@+id/textview_article_title"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- </TextView>
- <TextView
- android:id="@+id/textview_article_abstract"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- </TextView>
- <TextView
- android:id="@+id/textview_article_url"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="10dp">
- </TextView>
- </LinearLayout>
在res/drawable目录下,有一个border.xml文件定义了MainActivity界面上的ListView的背景,它的内容如下所示:
- <?xmlversion="1.0"encoding="utf-8"?>
- <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:gravity="center">
- <LinearLayout
- android:orientation="horizontal"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="24dp"
- android:text="@string/title">
- </TextView>
- <EditText
- android:id="@+id/edit_article_title"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- </EditText>
- </LinearLayout>
- <LinearLayout
- android:orientation="horizontal"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/abs">
- </TextView>
- <EditText
- android:id="@+id/edit_article_abstract"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- </EditText>
- </LinearLayout>
- <LinearLayout
- android:orientation="horizontal"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="27dp"
- android:text="@string/url">
- </TextView>
- <EditText
- android:id="@+id/edit_article_url"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- </EditText>
- </LinearLayout>
- <LinearLayout
- android:orientation="horizontal"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:gravity="center"
- android:layout_marginTop="10dp">
- <Button
- android:id="@+id/button_modify"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/modify">
- </Button>
- <Button
- android:id="@+id/button_delete"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/delete">
- </Button>
- <Button
- android:id="@+id/button_add_article"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="16dp"
- android:paddingRight="16dp"
- android:text="@string/add">
- </Button>
- <Button
- android:id="@+id/button_cancel"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/cancel">
- </Button>
- </LinearLayout>
- </LinearLayout>
- <?xmlversion="1.0"encoding="utf-8"?>
- <shapexmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="rectangle">
- <solidandroid:color="#ff0000ff"/>
- <strokeandroid:width="1dp"
- android:color="#000000">
- </stroke>
- <paddingandroid:left="7dp"
- android:top="7dp"
- android:right="7dp"
- android:bottom="7dp">
- </padding>
- <cornersandroid:radius="10dp"/>
- </shape>
- <?xmlversion="1.0"encoding="utf-8"?>
- <resources>
- <stringname="app_name">Article</string>
- <stringname="article">Article</string>
- <stringname="add">Add</string>
- <stringname="modify">Modify</string>
- <stringname="delete">Delete</string>
- <stringname="title">Title:</string>
- <stringname="abs">Abstract:</string>
- <stringname="url">URL:</string>
- <stringname="ok">OK</string>
- <stringname="cancel">Cancel</string>
- </resources>
更多相关文章
- android 手机虚拟按键 震动过程的追溯(1)
- Ubuntu 编译Android若干错误及解决方法
- android 打开电子市场中应用的界面
- 移植TM**到Android(安卓)| 编译
- Android(安卓)7.0 FileUriExposedException 的处理
- Android(安卓)由图片资源ID获取图片的文件名
- Android(安卓)内核编绎错误解决方案
- android中禁止GridView上下滑动的方法
- 将Android(安卓)SQLite db 文件转化成xml保存在xml