登录
首页 » Android » Android OnClickListener监听接口用法范例

Android OnClickListener监听接口用法范例

于 2023-05-27 发布 文件大小:36.43 kB
0 34
下载积分: 2 下载次数: 1

代码说明:

Android OnClickListener监听接口用法范例,基础级的例子,   Button button = (Button) findViewById(R.id.Button01);//获取屏幕中的按钮控件对象   button.setOnClickListener(//为按钮对象添加OnClickListener接口实现    //OnClickListener为View的内部接口,其实现者负责监听鼠标点击事件   new View.OnClickListener(){   public void onClick(View v){   LinearLayout ll=(LinearLayout)findViewById(R.id.lla);//获取线性布局对象   String msg=LinearActivity.this.getResources().getString(R.string.button);   Button tempbutton=new Button(LinearActivity.this);//创建一个Button对象   tempbutton.setText(msg+(++count));//设置Button控件显示的内容   tempbutton.setWidth(80);//设置Button的宽度   ll.addView(tempbutton);//向线性布局中添加View   System.out.println("========= count"+count);

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 腾讯新浪微博模拟登录最新源码
    腾讯新浪微博模拟登录最新源码
    2013-04-22下载
    积分:1
  • 扫描枪精简demo
    通过USB接口 监听键盘事件 获取扫描结果
    2023-06-10 11:50:06下载
    积分:1
  • 远程视频监控
    【核心代码】 public interface CameraSource {  static final String LOG_TAG = "camera";  /**  * Open the camera source for subsequent use via calls to capture().  *   * @return true if the camera source was successfully opened.  */  boolean open();  /**  * Close the camera source. Calling close on a closed CameraSource is  * permitted but has no effect. The camera source may be reopened after  * being closed.  */  void close();  /**  * The width of the captured image.  *   * @return the width of the capture in pixels  */  int getWidth();  /**  * The height of the captured image.  *   * @return the height of the capture in pixels  */  int getHeight();  /**  * Attempts to render the current camera view onto the supplied canvas.  * The capture will be rendered into the rectangle (0,0,width,height).  * Outstanding transformations on the canvas may alter this.  *   * @param canvas the canvas to which the captured pixel data will be written  * @return true iff a frame was successfully written to the canvas  */  boolean capture(Canvas canvas);  boolean saveImage(String savePath, String fileName); }
    2013-12-04下载
    积分:1
  • 商品简单管理
    实现登录注册,对商品的增删改差的操作
    2022-08-22 16:58:14下载
    积分:1
  • Android毛玻璃效果处理类 附示例源码
    Android毛玻璃效果处理类 附示例源码,方法封装,实现简单,代码里有详细注释,有需要的朋友可以去下载。相关代码先睹为快:   Bitmap bmp = BitmapFactory.decodeResource(getResources(),id);//从资源文件中得到图片,并生成Bitmap图片   final Bitmap blurBmp = BlurUtil.fastblur(MainActivity.this, bmp, 10);//0-25,表示模糊值   final Drawable newBitmapDrawable = new BitmapDrawable(blurBmp); // 将Bitmap转换为Drawable   layout.post(new Runnable() //调用UI线程   {    public void run()    {    layout.setBackgroundDrawable(newBitmapDrawable);//设置背景    }   });
    2022-04-07 03:49:35下载
    积分:1
  • opengles实现ms3d,md2,3ds,obj模型文件的加载和动画
    opengles实现ms3d,md2,3ds,obj模型文件的加载和动画,这个程序将更好的帮助你理解骨骼动画的原理和模型动画文件的加载,解析等等
    2022-02-24 18:38:24下载
    积分:1
  • android 登陆界面设计,可以保存多个账号,有下拉选择账号功能
    android 登陆界面设计,可以保存多个账号,有下拉选择账号功能。封装的原生demo可以直接运行,可以参考。
    2023-04-03 11:00:04下载
    积分:1
  • android 定时打电话源码
    打电话 定时 android
    2023-06-22 06:30:03下载
    积分:1
  • SpnOverride
    private HashMap Source Code for Andriod.
    2013-12-13 14:51:23下载
    积分:1
  • android 异步加载资源示例源码下载
    android 异步加载资源示例源码下载
    2014-02-09下载
    积分:1
  • 696522资源总数
  • 104029会员总数
  • 31今日下载