zoukankan      html  css  js  c++  java
  • android学习(2)

    1.开发Activity步骤
    第一步:写一个类继承Activity
    第二步:重写oncreate方法
    第三步:在主配置文件中注册activity
    <activity android:name=".类名"
    android:label="@string/app_name">
    <intent-filter>
    <!--app的入口-->


    <action android:name="android.intent.action.MAIN" />


    <!--桌面显示-->
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    2.Activiry常用方法
    View findViewById(int id)//根据组件的ID取得组件对象
    setContentView(int layoutResID)//设置布局文件,设置显示组件
    3.TextVies
      android:maxLength=""      //允许最字符数


      android:textColor=""       //文字的颜色
      android:textSize=""       //文字大小
      android:textStyle=""       //文字样式
      android:password=""      //是否以密文方式显示
      android:layout_margin=""    //外边距
      android:background=""      //背景样式
      android:id="" //设置id的值

      getText().toString() //获得控件的文本内容
      setText() //设置控件的文本内容
    注意:<!-- -->注释

    4.EditText(文件编辑框)

      android:password=""          //是否以密文方式显示

      android:enabled="false"          //设置是否可用,false不能用

      android: hint=””                       //水印

      android: numeric=”integer”                   //只能输入数字

    5.Button(按钮控件)

    6.RadioButton(单选按钮)

                嵌入到RadioGroup中实现单选效果

                    android: checkedButton=”radio的id值 ”;

                int getCheckedRadioButtonId( );                    //获得被选中的单选按钮的id

    7.CheckBox(复选框)

                    android: checked=”true”;                               //设置默认选中

                    CheckBox(Context context)                            //实例化CheckBox组件

                void setChecked(boolean checked)     //设置默认选中

    8.ImageView(图片控件)

                android: maxHeight=” ”;                                //图片的最大高度

                android: maxWidth=” ”;                                 //图片的最大宽度

                android: src=” ”;                                                         //图片的资源ID

                android: adjustViewBounds=” ”;         //设置为true,则maxHeight和maxWidth

    9.ImageButton(图片按钮)

    10.TimePicker(时间选择器)

        setIs24HourView(true);             //设置24小时制

        setCurrentHour();       //设置小时

        setCurrentMinute();      //设置分钟

    11.DatePicker(日期控件)


    //修改日期


    void updateDate(int year,int monthofYear, int dayOfMonth)


    注意:monthOfYear是从0-11表示1-12月

  • 相关阅读:
    Java反射机制DOME
    Contos7 装bcm4312无线网卡驱动
    windows8.1+centos7双系统(装完centos后无win8引导)
    request+response
    HTTP协议+servlet配置
    类加载和反射
    线程池+线程安全
    IO流之Properties(String键值对)+序列流+打印流+commons-IO(最终流程)
    IO流之字节流 +字符流 (复制文件)
    IO流
  • 原文地址:https://www.cnblogs.com/etid/p/6867590.html
Copyright © 2011-2022 走看看