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月

  • 相关阅读:
    最大子数组求和并进行条件组合覆盖测试
    Ubuntu 16.04 c++ Google框架单元测试
    The directory '/home/stone/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If execu
    Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then appstreamcli refresh > /dev/null; fi'
    个人博客作业三:微软小娜APP的案例分析
    补交 作业一
    补交 作业二:个人博客作业内容:需求分析
    嵌入式软件设计第12次实验报告
    嵌入式软件设计第11次实验报告
    嵌入式软件设计第10次实验报告
  • 原文地址:https://www.cnblogs.com/etid/p/6867590.html
Copyright © 2011-2022 走看看