欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android自定義可標(biāo)記日歷效果

 更新時間:2017年05月20日 14:24:08   作者:genius-x  
這篇文章主要為大家詳細(xì)介紹了Android自定義可標(biāo)記日歷效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下

先直接看看效果吧

初始情況

點擊一個作為標(biāo)記

再次點擊后刪除

3.這里還要感謝前輩的代碼作為參考,畢竟以前也沒有寫過關(guān)于日歷方面的東西,別人確實寫得不錯,我在原基礎(chǔ)上加入了數(shù)據(jù)庫操作等補充,以完成自己實際需求,作為尊重首先給出原作者的連接

就是這里–>Android自定義控件實現(xiàn)可多選課程日歷CalendarView

4.然后貼出來關(guān)于數(shù)據(jù)庫操作的代碼,給大家作為參考

DatabaseHelper .java 這是關(guān)于簡單數(shù)據(jù)庫操作的部分

package com.xugongming38.editcalendar.utils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by dell on 2017/5/18.
 */

public class DatabaseHelper extends SQLiteOpenHelper {
 public static final String CREATE_DIARY = "create table Hair("
   + "id integer primary key autoincrement, "
   + "content text)";

 private Context mContext;

 public DatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){
  super(context, name, factory, version);
  mContext = context;
 }
 @Override
 public void onCreate(SQLiteDatabase db) {
  db.execSQL(CREATE_DIARY);
 }

 @Override
 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

  db.execSQL("drop table if exists Hair");
  onCreate(db);
 }
}

DataHelper .java 簡化數(shù)據(jù)操作接口,避免直接操作數(shù)據(jù)庫,做了再一層的封裝,建議讀者也這樣做,可以讓代碼更清晰,更容易復(fù)用

package com.xugongming38.editcalendar.utils;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dell on 2017/5/18.
 */

public class DataHelper {
 public static DatabaseHelper mHelper;
 public static void deleteData2List(String content) {
  SQLiteDatabase dbDelete = mHelper.getWritableDatabase();
  dbDelete.delete("Hair", "content = ?", new String[]{content});

 }
 public static void addData2List(String content) {
  SQLiteDatabase db = mHelper.getWritableDatabase();
  ContentValues values = new ContentValues();

  values.put("content", content);
  db.insert("Hair", null, values);
  values.clear();
 }
 public static List<String> getDataList(Context context) {

  if(mHelper==null){
   mHelper = new DatabaseHelper(context, "Hair.db", null, 1);
  }
  List<String> dataList = new ArrayList<>();

  SQLiteDatabase sqLiteDatabase = mHelper.getWritableDatabase();
  Cursor cursor = sqLiteDatabase.query("Hair", null, null, null, null, null, null);


  if (cursor.moveToFirst()) {
   do {
    String content = cursor.getString(cursor.getColumnIndex("content"));
    dataList.add(content);
   } while (cursor.moveToNext());
  }
  cursor.close();


  return dataList;
 }
}

5.代碼完整部分下面給出GitHub地址,歡迎star,水平有限,如有需要,歡迎留言討論

這是我的github位置–https://github.com/xugongming38/EditCalendar

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android自定義加載圈動畫效果

    Android自定義加載圈動畫效果

    這篇文章主要為大家詳細(xì)介紹了Android自定義加載圈動畫效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • Android自定義播放器控件VideoView

    Android自定義播放器控件VideoView

    這篇文章主要介紹了Android自定義播放器控件VideoView的相關(guān)資料,需要的朋友可以參考下
    2016-01-01
  • Android中標(biāo)簽容器控件的實例詳解

    Android中標(biāo)簽容器控件的實例詳解

    在Android開發(fā)過程中,常常會遇到這樣的場景:我們展示一種物品或者為某一事物添加一些標(biāo)簽。比如說,我們買一件衣服,可以有以下幾種標(biāo)簽:杰克瓊斯,男士,運動等等。本文將實例介紹Android中標(biāo)簽容器控件的實現(xiàn)過程。
    2016-07-07
  • Android Flutter實現(xiàn)上拉加載組件的示例代碼

    Android Flutter實現(xiàn)上拉加載組件的示例代碼

    既然列表有下拉刷新外當(dāng)然還有上拉加載更多操作了,本次就為大家詳細(xì)介紹如何利用Flutter實現(xiàn)為列表增加上拉加載更多的交互,感興趣的可以了解一下
    2022-08-08
  • Android開發(fā)Jetpack組件Lifecycle原理篇

    Android開發(fā)Jetpack組件Lifecycle原理篇

    這一篇文章來介紹Android?Jetpack架構(gòu)組件的Lifecycle;?Lifecycle用于幫助開發(fā)者管理Activity和Fragment?的生命周期,?由于Lifecycle是LiveData和ViewModel的基礎(chǔ);所以需要先學(xué)習(xí)它
    2022-08-08
  • Android  SQLite數(shù)據(jù)庫徹底掌握數(shù)據(jù)存儲

    Android SQLite數(shù)據(jù)庫徹底掌握數(shù)據(jù)存儲

    這篇文章主要介紹了 Android SQLite數(shù)據(jù)庫的相關(guān)資料,這里對Android SQLlite做了詳細(xì)介紹,需要的朋友可以參考下
    2016-10-10
  • Android開發(fā)教程之shape和selector的結(jié)合使用

    Android開發(fā)教程之shape和selector的結(jié)合使用

    shape和selector是Android UI設(shè)計中經(jīng)常用到的,比如我們要自定義一個圓角Button,點擊Button有些效果的變化,就要用到shape和selector,接下來通過本文給大家介紹Android開發(fā)教程之shape和selector的結(jié)合使用,感興趣的朋友一起學(xué)習(xí)吧
    2016-01-01
  • android之計時器(Chronometer)的使用以及常用的方法

    android之計時器(Chronometer)的使用以及常用的方法

    在Android的SDK中,為我們提供了一個計時器,這個計時器稱為Chronometer,我們可以成它為Android的一個組件,同時它也具備自己獨有的方法
    2013-01-01
  • Android簡單使用PopupWindow的方法

    Android簡單使用PopupWindow的方法

    這篇文章主要為大家詳細(xì)介紹了Android簡單使用PopupWindow的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-03-03
  • 詳解androidstudio項目上傳到github方法以及步驟

    詳解androidstudio項目上傳到github方法以及步驟

    在使用studio開發(fā)的項目過程中有時候我們想將項目發(fā)布到github上,studio其實是自帶這種功能的,那么如何使用呢,下面我們就一起來了解一下
    2019-01-01

最新評論