My Android Case-sign-in Calendar

Source: Internet
Author: User
Tags date1

2015 Android Case tour case eight: Registration calendar knowledge Points:
    1. Use of the GridView
    2. Use of SQLite
Documents involved:
    1. Res->layout->activity_main.xml Main layout file
    2. Res->layout->date.xml Layout file
    3. Src->db->dbhelper.javajava file
    4. Src->db->signdao.javajava file
    5. Src->activity->mainactivity.javajava file
Activity_main.xml
<!--linear layout--><linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"    android:layout _height= "Match_parent"    android:layout_width= "match_parent"    android:orientation= "vertical" >    < !--Text Control    Displays the current month--    <textview         android:id= "@+id/show"        android:gravity= "center"        android: Layout_width= "Match_parent"        android:layout_height= "wrap_content"        android:text= "month"/>    <!-- Grid View-    <gridview         android:id= "@+id/mydate"        android:layout_width= "Match_parent"        android:layout_height= "355DP"        android:numcolumns= "7" ></GridView>    <button         Android:id= "@+id/sign"        android:layout_width= "match_parent"        android:layout_height= "Wrap_content"        android:text= "Sign in"/></linearlayout>
Date.xml
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android"    android:layout_width= "Match_ Parent "    android:layout_height=" match_parent "    android:orientation=" vertical ">        <textview        Android:id= "@+id/txtweekdatemb"        android:layout_width= "wrap_content"        android:layout_height= "Wrap_ Content "        android:layout_marginleft=" 10DP "        android:layout_margintop=" 10DP "        android:visibility=" gone "/>    <textview        android:id=" @+id/txtdaydatemb "        android:layout_width=        " Wrap_content " android:layout_height= "Wrap_content"        android:layout_marginleft= "10DP"        android:layout_margintop= "10DP "/></linearlayout>
Mainactivity.java
public class Mainactivity extends Activity {//log label private static final String tag = "sign";//Declare Object private Button Sign;priv Ate TextView show;private GridView mydate;//get local time-nowtime = new Times ();//days in one months private int daymaxnum;private int yea R,month,day,ym;private Signdao sdao;//Query result private list<string> List = new arraylist<string> ();p rivate ArraylistDbhelper.java
public class DBHelper extends Sqliteopenhelper {public DBHelper (context context) {Super (context, "sign.db", NULL, 1);} /** * @param CREATE TABLE */@Overridepublic void OnCreate (Sqlitedatabase db) {String sql= "CREATE TABLE Sintb (" + "sin_id integer prim ary key AutoIncrement, "+" userid varchar (a), "+" usernmae varchar (+), "+" sindate varchar (20), "+" yearmonth varchar, "+" Nowdate integer "+") ";d b.execsql (SQL);} /** * This method is called when @param database version is updated */@Overridepublic void Onupgrade (sqlitedatabase db, int oldversion, int newversion) {}}
Signdao.java
public class Signdao {//Declare object context context; Sqlitedatabase db;dbhelper dbhelper;public Signdao (context context) {This.context = context;}  /** * @param Open database Connection */public Boolean open () {dbhelper = new DBHelper (context);d B = dbhelper.getwritabledatabase (); if (db = = NULL) {return false;} return true;} /** * @param close connection */public void Close () {dbhelper.close ();} /** * @param Insert information * @param UID * @param name * @param date * @param ym */public void Insertsininfo (String uid,string name,s Tring date,string month) {String sql= "insert into SINTB (userid,usernmae,sindate,yearmonth,nowdate) VALUES (?,?,?,?,?)"; Db.execsql (Sql,new Object[]{uid,name,date,month,system.currenttimemillis ()}); /** * @param query information * @param UID * @param date * @param ym * @return */public arraylist





My Android Case-sign-in Calendar

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.