源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android编程实现简单设置按钮颜色的方法

  • 时间:2020-05-06 05:19 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android编程实现简单设置按钮颜色的方法
本文实例讲述了Android编程实现简单设置按钮颜色的方法。分享给大家供大家参考,具体如下: [b]1.工程目录[/b] a.在res目录-新建drawble文件夹放入自定义图片 [img]http://files.jb51.net/file_images/article/201703/20173293750525.jpg?20172293916[/img] [b]2.main.xml[/b]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  >
<TextView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="@string/hello"
  />
  <ImageButton
  android:id="@+id/button"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:background="#000000"
  android:src="@drawable/sy"
  />
</LinearLayout>

[b]3.类代码[/b]
package com.YANSE;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageButton;
public class YANSE extends Activity {
  private ImageButton Image =null;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Image=(ImageButton)findViewById(R.id.button);
  }
}

更多关于Android相关内容感兴趣的读者可查看本站专题:《[url=http://www.1sucai.cn/Special/371.htm]Android布局layout技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/375.htm]Android视图View技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/410.htm]Android开发入门与进阶教程[/url]》、《[url=http://www.1sucai.cn/Special/508.htm]Android调试技巧与常见问题解决方法汇总[/url]》、《[url=http://www.1sucai.cn/Special/398.htm]Android多媒体操作技巧汇总(音频,视频,录音等)[/url]》、《[url=http://www.1sucai.cn/Special/381.htm]Android基本组件用法总结[/url]》及《[url=http://www.1sucai.cn/Special/124.htm]Android控件用法总结[/url]》 希望本文所述对大家Android程序设计有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部