zoukankan      html  css  js  c++  java
  • android

    ***************
    time:2016.7.12
    theme:andriod interduce
    第一节布局
    ***************************
    Four part : activity / server/ broadcastReciver /contentProvider/


    5大布局:linearlayout/ relativelayout

    属性:loyout_width=""
    layout_height=""
    layout_text=""
    layout_alig
    layout_gravity=""center_horizontal"
    *******************************************
    第二节


    每当我们看到一些美妙的设计的时候,很多人心里面会有一种冲动,
    这种冲动会让你们想去创造一些 新的东西,创造一些美妙的事物
    <EditText
    androdi:layout_height="fill_parent"
    androdi:layout_width=
    androdi:layout_inputType=""


    android:"@+id/for the textview'name"/>

    ************
    Q&A:empty and with null.

    String value = et.getText().toString().trim();
    if(value==null|| value.equals("")){
    et.setError("CAN NOT EMPTY");
    }

    ***************************************************************************************************
    view
    Android应用中的每个界面都是一个Activty
    Activity上展现的都是Android系统中的可视化组件
    Android中的任何可视化组件都是从android.view.View继承


    View类有很多子类:
    Layout/View Container/

    分为三种 布局类(Layout):
    继承于ViewGroup类 视图容器类(View Container):
    继承于ViewGroup类 视图类:
    继承于View类

    findViewById获取xml中的view对象

    View类定义了一系列的内嵌监听器类


    输入框可以采用监听焦点事件来实现用户输入验证

    Intent:实现在Activity与Activity之间的切换
    // date trasport
    Intent intent = new Intent(activity.this,BActivity.class);
    intent.putExtra("name","andy");


    // object trasport(need to new a Person class)
    Person p = new Person();
    P.setName("andy");
    P.setAge("11");
    Bundle b = new Bundle();
    b.putSerializable("people",p);//(content for object)
    intent.putectras(b);


    //get the object.
    Bundle b= i.getExtras();
    Person p =(person)b.get("person");

    //集合
    List<String>list = new ArrayList<String>();
    list.add("dd");
    list.add("aa");
    b.putSerizable("list",list.toArray());
    intent.Extras()


    //接收集合
    Object[] obj = (object[])b.get("list");
    List<String>list = new ArrayList<String>;
    for(obj=0;obj++;object<=){}//输出


    **************************************************
    在Android中startActivityForResult主要作用就是:

    Intent intent = new Intent(activity.this,BActivity.class);

    startActivityForResult //请求1


    ********************
    测试方法:Toast.mkaeText(MainActivty.this , "context",duratiojn).show();

    Button注册监听,监听器采用匿名类实现:

    @Override OnCreate() method.
    super.onCreate(savedInstanceState) find the 布局
    setContentView()找组件
    publice void onClick(View v){事件处理}

    **************************************************************************************

    一个文本编辑框:
    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="25sp"
    android:text="please input your number"
    />

    一个文本输入框:
    <EditText
    android:id="@+id/guessed"
    android:hint = "InputNumber"
    android:numeric="integer"
    android:digits="1234567890"
    android:singleLine="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="67dp"
    android:ems="15" />
    Button按钮:
    <Button
    android:id="@+id/enter"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/guessed"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="14dp"
    android:text="binggo" />
    <Button
    android:id="@+id/continuebut"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:text="go on" />

    &&&&&&&&&&&&&&&&&&&&&&&&&&&
    adpater:
    item.xml:构建子布局。
    main.xml:构建总布局。
    mainActivity:
    item:封装子布局的数据。
    Myadapter:create your own adpter
    ****************************************

    GridView.


    ***************************************************************************************************
    time:2016.7.15 morning
    theme:framgmet
    ***********************
    1.new class named TitleFragment.

    2.import android support.v4.Fragmet


    3.rewrite onCreteView methond.

    (1.find layout 2.find form widgets)

    4.find layout:(?inflate,Toast)
    View view =inflater.inflate(R.layout.title, null);


    5.find form:


    **************************


    *************************
    配置文件mainfiest
    bottom:
    bottom.xml:<ImageView />
    content.xml
    TiletFragmet.class:extends Fragment @Override oncreateView()

    BottomFragmet.java

    ContentFragmet.class:extends Fragment @Override oncreateView()
    MainActivity.java:

    <-title->

    <fragment
    id
    name
    width
    height
    >

    <-content->
    <Fragment
    id
    name
    width
    height
    layout_above
    ></Fragment>

    <-Bottom->
    <fragment
    id
    name
    width
    height
    layout_al
    >


    MainActivity
    MainActivity extends Fragment
    private iv;
    private type of fragment
    //find the form iv=findViewById(R.id.name);
    name.setOnClickListener(this);
    @override
    public void onClick(){
    swith(v.getId())
    {
    case R.Id.getvi

    }
    }
    //set show fragment
    priate void setFragment(fragment obj)

    {
    //get the FragmentMange

    FragmentManager name =getSupportFragmentManager()
    //open a action
    FragmentTransation transation = name.beginTransation();
    transation.replace(arg0,arg1)
    //replace the fragment 当前位置
    //int arg0 fragment要放置的位置
    //int arg1 目标fragment

    tansation.commit();
    }

    ***************************************************************************************************
    time:2017.7.15 afternoon
    theme:SQLite operation:
    ***************************************************************************************************
    SQLite 数据库:

    SQLite数据库,它是轻量级的嵌入式数据库。


    SQLiteOpenHelper

    SQLiteOpenHelper是一个抽象类,需要实现如下方法:

    onCreate(SQLiteDatabase db)
    onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion)

    调用getWritableDatabase()可以获得可写的SQLiteDatabase对象。
    调用getReadableDatabase()可以获得一个只读的SQLiteDatabase对象


    *************************&&&&&&&&&&
    一.create the page and some class for the database :
    com.etc.util

    //创建表 private

    2.created ;
    class Untils(){
    public static final String Datebase_Name="finn.db(database name)";

    public static final String Datebas_table="Users";//table

    public static final String Datebas_version=1;

    }
    3.created ;
    com.etc.db

    4.created ;
    public class MySQLiteOpenHelper exntend SQLiteOpenHelper(){

    private Context Context;


    }
    ********************************
    //create构造函数
    创建db表
    //onCreate
    Sring sql="create table" +"Until.Datebase_table_name+"(id primary key autoincrement,name text no null,pwd text no null);
    db.excSQL(sql);

    //Updagrade

    Sting sql="drop table if exit"+Until.Datebase_table_name;
    db.execSQL(sql);
    onCreate(do);

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    二,create some interface
    //com.etc.dao
    用户dao包 write interface
    d{

    //????????????

    pubilc int addUser(String name,String pwd);

    //login

    public boolen checkLogin(String name,String pwd);


    }


    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    三.interface 实现 增删改查
    puilc class UserDapImpl implements UserDao(){


    private Context;
    private MySQLiteOpenHelper helper;// created db class

    private SQLiteDatabase database; //operation class (curd)
    private Cursor;


    //the interface impl to the add user.
    pubilc int addUser(String name,String pwd);

    open();
    dateabase=helper.getwritableDatabase(); ????for what?
    //intert(String table,String nullColumHack,ContentValues values)
    ContentValues values = new ContentValues();
    values.put("name",name);
    values.put("pwd",pwd);


    datebase.intert(String table,String nullColumHack,ContentValues values)

    count =(int)

    closeAll();
    return count;

    //the interface for the login

    public boolen checkLogin(String name,String pwd);

    open();
    dateabase=helper.getwritableDatabase(); ///////?what is helper.getwritableDatebase(); used for??

    String[]=colums=("name""pwd");

    //select * from user where='clh' and pwd='123'

    Sting selection="name='"name+"'''"; ///???what the fuck?????

    //?
    Cursor cursor= datebase.query( Until.Database_table_name,colums ,selection,null,null,null,null );
    //返回结果集定义全局变量Cursor//helper?

    if(cursor){

    ///???? H T D IT???
    }

    count =(int)

    closeAll();
    return 0;

    }

    ******************************************************************************
    注册实现:
    pulic void onClick(View v){


    switch (v.getid())
    {
    case R.id.lr_regiset;//login


    Sring username=name.getText().toString();
    Sring pwd=pwd.getText().toString();

    if(uesrname.equals("")||userpwd.equals(""))
    {
    name.setError("cant be empty");

    }else{
    //// dont know how to ...
    int count =userdao.addUser(username,userpwd);
    Toast.makeText(MainActivity.this,"注册成功",+count+"个用户",0).show();
    }

    break;

    case R.id.lr_login //login

    boolean flag = userdao.checkLogin(username,userpwd);
    if(flag){
    Intent intent = new intent ///?????????????

    }

    }
    **********************************************
    //跳转activity
    ///public class ShowAllUser extends Activity(){

    private ListView;
    private List<user> list;
    //从写onCreate()方法///????????????????????????


    list<string> namelist= new ArrayList<string>;
    for(int i =0;i<list.size();i++){
    //??????????????


    }
    ///????adaoter<>

    }

    *********************************
    查找:
    public List<user>queryUserAll(){
    open();
    database=helper.getReadablebase();
    Sring[] colums={"id","name","pwd"};
    Cursor cursor= datebase.query( Until.Database_table_name,colums ,selection,null,null,null,null );
    //遍历结果集


    if(cursor.getCount!=0){

    cursor.moveToFirst();
    do{
    //excute then do
    int id = cursor getInt(cursor.getColumIndexOrThrow("id")); ////wtf?
    String name =cursor.getString(cursor.getColumIndexOrThrow("name"));
    String pwd =cursor.getString(cursor.getColumIndexOrThrow("pwd"));

    user user = new User(id,name,pwd);
    list.add(user);


    }
    while(cursor.moveToNext());
    }


    closeALL();
    return list;
    }

  • 相关阅读:
    redis——事务
    redis——队列
    linux安装mysql5.7
    转载:centos7yum默认为阿里云镜像
    redis——缓存穿透、缓存击穿、缓存雪崩
    redis——持久化
    redis——分布式锁
    并发编程实践
    Java并发包中线程同步器
    并发包中ScheduledThreadPoolExecutor
  • 原文地址:https://www.cnblogs.com/a-n-dy/p/5767161.html
Copyright © 2011-2022 走看看