SQLiteOpenHelper
类。通过重写其onCreate()
和onUpgrade()
方法来执行SQL语句。,,``java,public class MyDatabaseHelper extends SQLiteOpenHelper {, private static final String DATABASE_NAME = "mydatabase.db";, private static final int DATABASE_VERSION = 1;,, public MyDatabaseHelper(Context context) {, super(context, DATABASE_NAME, null, DATABASE_VERSION);, },, @Override, public void onCreate(SQLiteDatabase db) {, db.execSQL("CREATE TABLE mytable (id INTEGER PRIMARY KEY, name TEXT)");, },, @Override, public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {, db.execSQL("DROP TABLE IF EXISTS mytable");, onCreate(db);, },},
``Collections.sort()
方法对数据源进行排序,然后调用notifyDataSetChanged()
方法刷新列表视图。,,``java,Collections.sort(dataList, new Comparator() {, @Override, public int compare(MyData o1, MyData o2) {, return o1.getField().compareTo(o2.getField());, },});,adapter.notifyDataSetChanged();,
``getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
实现屏幕常亮功能。AlertDialog.Builder
来创建一个带图标的列表对话框。通过调用 setIcon
方法设置对话框的图标,然后使用 setItems
方法或 setSingleChoiceItems
方法添加列表项。调用 create()
方法生成并显示对话框。Powered By Z-BlogPHP 1.7.3