• Android 日常总结的一些方法使用


    1. setImageResource : 更改图片的资源

    2. setClickable :  设置为true时,表明控件可以点击,如果为false,就不能点击 .  注意,setOnClickListener方法会默认把控件的setClickable设置为true。

    3. setEnable  :    使能控件,如果设置为false,该控件永远不会活动,不管设置为什么属性,都无效;设置为true,表明激活该控件,控件处于活动状态,处于活动状态,就能响应事件了,比如触摸、点击、按键事件等;

     两个按键的区别 :

     其实区别就在上面说的几个小地方,总的来看,setEnabled()相当于总开关,控制着按钮的状态,而setClickable()相当于具体的某个开关,控制这个开关是否可以点击。

    4. setListAdapter(adapter)  : 它是ListActivti里面一个方法,它的ListView的ID必须为android:id = @id/list

    5.查看手机的是user还是userdebug   : adb shell getprop ro.build.type

    6.this.getResources().getStringArray : 得到xml文件中的String的数组数据源

    7. class buttonText implements CompoundButton.OnCheckedChangeListener{

        @Override        //覆写上面的方法
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        CompoundButton buttonView  :  这个为点击控件的对象
        boolean isChecked : 判断是否选中

    }
    }
    8. radiobutton 去掉那个小圆圈的图标-------------> android:button=@null;
                                android:src = @drawable/下面的资源
    9.
      <RadioButton
    android:drawablePadding="5dp"
    android:layout_gravity="center"
    android:gravity="center"
    android:button="@null" ---------------->去掉RadioButton的小圆圈并添加背景
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:drawableTop="@mipmap/ic_launcher" --------------->把图片放在上面,文本写在下面(Button也可以设置)
    android:text="你好" />
  • 相关阅读:
    eslint 翻译
    .prettierrc
    轻松掌握golang的defer机制
    golang的逃逸分析
    《python解释器源码剖析》第17章--python的内存管理与垃圾回收
    《python解释器源码剖析》第16章--python的多线程机制
    《python解释器源码剖析》第15章--python模块的动态加载机制
    MongoDB:最受欢迎的文档型数据库
    (持续更新中)opencv:处理图像的高性能模块
    (写了一点写不下去了,虽然垃圾但又不想扔)nginx--最流行的web服务器
  • 原文地址:https://www.cnblogs.com/liunx1109/p/9850397.html
Copyright © 2020-2023  润新知