以下是一个简单的布局文件代码示例,用于保存新闻到 SQLite 数据库:

<!-- activity_main.xml -->
<LinearLayout xmlns:android='http://schemas.android.com/apk/res/android'
    xmlns:tools='http://schemas.android.com/tools'
    android:layout_width='match_parent'
    android:layout_height='match_parent'
    android:orientation='vertical'
    android:padding='16dp'
    tools:context='.MainActivity'>

    <EditText
        android:id='@+id/editTextTitle'
        android:layout_width='match_parent'
        android:layout_height='wrap_content'
        android:hint='标题' />

    <EditText
        android:id='@+id/editTextContent'
        android:layout_width='match_parent'
        android:layout_height='wrap_content'
        android:hint='内容' />

    <Button
        android:id='@+id/buttonSave'
        android:layout_width='wrap_content'
        android:layout_height='wrap_content'
        android:text='保存' />

</LinearLayout>

这个布局文件包含了一个标题输入框(EditText)、一个内容输入框(EditText)和一个保存按钮(Button)。

您可以根据自己的需求进行修改和扩展。在 Java 代码中,您可以使用 SQLiteOpenHelper 类来创建和管理 SQLite 数据库以及相关的操作。


原文地址: https://www.cveoy.top/t/topic/o4S3 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录