日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android数据库 分页查询,Android之怎么使用SQLite数据库(增、删、改、查、分页等)以及ListView显示数据(转)...

發布時間:2023/12/10 Android 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android数据库 分页查询,Android之怎么使用SQLite数据库(增、删、改、查、分页等)以及ListView显示数据(转)... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

由于剛接觸android開發,故此想把學到的基礎知識記錄一下,以備查詢,故此寫的比較啰嗦:

步驟如下:

一、介紹:

此文主要是介紹怎么使用android自帶的數據庫SQLite,以及把后臺的數據用ListView控件顯示

二、新建一個android工程——DBSQLiteOperate

工程目錄:

三、清單列表AndroidManifest.xml的配置為:

< ?xml version="1.0" encoding="utf-8"?>

< manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.example.dboperate"

android:versionCode="1"

android:versionName="1.0" >

android:icon="@drawable/ic_launcher"

android:label="@string/app_name" >

android:name=".DBSQLiteOperateActivity"

android:label="@string/app_name" >

android:targetPackage="com.example.dboperate"

android:label="Test for my app"/>

< /manifest>

四、main.xml配置清單:

< ?xml version="1.0" encoding="utf-8"?>

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical" >

android:layout_height="wrap_content"

android:orientation="horizontal" >

android:id="@+id/name"

android:layout_width="100dip"

android:layout_height="wrap_content"

android:text="@string/name"

android:gravity="center"/>

android:id="@+id/phone"

android:layout_width="100dip"

android:layout_height="wrap_content"

android:text="@string/phone"

android:gravity="center"/>

android:id="@+id/amount"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/amount"

android:gravity="center"/>

< /LinearLayout>

android:id="@+id/listView"

android:layout_width="fill_parent"

android:layout_height="fill_parent" >

< /LinearLayout>

五、item.xml配置清單:

< ?xml version="1.0" encoding="utf-8"?>

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="horizontal" >

android:id="@+id/name"

android:layout_width="100dip"

android:layout_height="wrap_content"

android:text="@string/name"

android:gravity="center"/>

android:id="@+id/phone"

android:layout_width="100dip"

android:layout_height="wrap_content"

android:text="@string/phone"

android:gravity="center"/>

android:id="@+id/amount"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/amount"

android:gravity="center"/>

< /LinearLayout>

六、string.xml配置清單:

< ?xml version="1.0" encoding="utf-8"?>

< resources>

Hello World, DBSQLiteOperateActivity!

ExampleDBSQLiteOperate8

姓名

電話

存款

< /resources>

七、DBSQLiteOperateActivity.java Activity類的源碼:

package com.example.dboperate;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import com.example.adapter.PersonAdapter;

import com.example.domain.Person;

import com.example.service.PersonService;

import android.app.Activity;

import android.database.Cursor;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.AdapterView;

import android.widget.AdapterView.OnItemClickListener;

import android.widget.ListView;

import android.widget.SimpleAdapter;

import android.widget.SimpleCursorAdapter;

import android.widget.Toast;

public class DBSQLiteOperateActivity extends Activity {

ListView listView;

PersonService personService;

OnItemClickListener listViewListener;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

listViewListener = new OnItemClickListener(){

@Override

public void onItemClick(AdapterView

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的Android数据库 分页查询,Android之怎么使用SQLite数据库(增、删、改、查、分页等)以及ListView显示数据(转)...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。