• 移动第四次作业


    package com.example.sql;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    import android.view.Menu;
    import android.view.View;
    import android.widget.Toast;
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            Aasql sql=new Aasql(this);
            sql.getReadableDatabase();
        }
        public void add(View v){
            Aasql sql=new Aasql(this);
            SQLiteDatabase db=sql.getReadableDatabase();
            db.execSQL("insert into stu(name,age) values('zansan',22)");
            Toast.makeText(this, "ok",0).show();
        }
    
    }
    package com.example.sql;
    import android.content.Context;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    
    
    public class Aasql extends SQLiteOpenHelper {
    
        public Aasql(Context context) {
            super(context, "student.db", null, 1);
            // TODO Auto-generated constructor stub
        }
        public void onCreate(SQLiteDatabase db) {
            // TODO Auto-generated method stub
            db.execSQL("create table stu(_id integer primary key autoincrement,name varchar(20),age integer)");
            
        }
        public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
            // TODO Auto-generated method stub
            
        }
    
        
    
    }
    <RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity" >
    
        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/textView1"
            android:layout_alignBottom="@+id/textView1"
            android:layout_alignParentRight="true"
            android:ems="10" />
    
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginTop="74dp"
            android:text="姓名" />
    
        <EditText
            android:id="@+id/editText2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/editText1"
            android:layout_below="@+id/editText1"
            android:layout_marginTop="33dp"
            android:ems="10" />
    
        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/editText2"
            android:layout_alignBottom="@+id/editText2"
            android:layout_alignLeft="@+id/textView1"
            android:text="年龄" />
    
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="142dp"
            android:layout_toRightOf="@+id/textView1"
            android:text="注册" 
            android:onClick="add"/>
    
    </RelativeLayout>
  • 相关阅读:
    Vue.js_础学习之DOM操作
    node REPL
    node npm
    Vue.js_getter and setter
    tomcat+nginx+redis实现均衡负载以及session共享
    深入浅出微服务框架dubbo(一):基础篇
    Linux下安装zip解压功能
    Linux下查看CPU型号,内存大小,硬盘空间的命令
    Linux查看系统信息命令
    MyBatis自动生成代码之generatorConfig配置文件及其详细解读
  • 原文地址:https://www.cnblogs.com/ld1017/p/14007057.html
Copyright © 2020-2023  润新知