zoukankan      html  css  js  c++  java
  • Android之ImageButton控件基础操作

    控件绑定(前台对应控件的id属性要设置为imageButton_light)

    private ImageButton imageButton_light;//定义一个ImageButton控件对象,名为imageButton_light
    imageButton_light = (ImageButton) this.findViewById(R.id.imageButton_light);//与前台名为imageButton的控件进行控件绑定

    设置点击监听器(前台对应控件的onClick属性要设置为onClick)

    imageButton_light.setOnClickListener(this);

    控件点击操作(前台对应控件的onClick属性要设置为onClick)

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.imageButton_light:{
                //do sth
                break;
            }
        }
    }

    更改控件背景图片

    imageButton_sos.setBackgroundResource(R.drawable.pic2);//假设默认图片为pic,在此更改为pic2

    设置控件Alpha值

    imageButton_light.getBackground().setAlpha(50);

    设置控件可用性

    imageButton_light.setEnabled(false);
    ** Then I looked up at the sky and saw the sun **
  • 相关阅读:
    指针数组、数组指针以及二维数组
    jquery的基本动画方法
    jquery面试需要看的基本东西
    bootstrap
    node全栈工程师
    setTimeout 0秒
    随便写的
    Bootstrap2和3的区别
    记忆的代码
    offsetWidth与scrollLeft
  • 原文地址:https://www.cnblogs.com/chenyangsocool/p/4518186.html
Copyright © 2011-2022 走看看