zoukankan      html  css  js  c++  java
  • 一手遮天 Android

    项目地址 https://github.com/webabcd/AndroidDemo
    作者 webabcd

    一手遮天 Android - view(自定义): 自定义组合控件

    示例如下:

    /view/custom/CustomView3Demo.java

    /**
     * 演示如何自定义组合控件,自定义的组合控件参见 view/custom/CustomView3.java(实现了一个简易的登录框)
     */
    
    package com.webabcd.androiddemo.view.custom;
    
    import androidx.appcompat.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Toast;
    
    import com.webabcd.androiddemo.R;
    
    public class CustomView3Demo extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_view_custom_customview3demo);
    
            CustomView3 customView3 = findViewById(R.id.customView3);
            customView3.setOnLoginListener(new CustomView3.OnLoginListener() {
                @Override
                public void login(View v, String username, String password) {
                    // 用户点击登录按钮后,可以拿到用户输入的用户名和密码
                    Toast.makeText(CustomView3Demo.this, String.format("username:%s, password:%s", username, password), Toast.LENGTH_SHORT).show();
                }
            });
        }
    }
    
    

    /layout/activity_view_custom_customview3demo.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <!--
            CustomView3 - 自定义组合控件(实现了一个简易的登录框)
        -->
        <com.webabcd.androiddemo.view.custom.CustomView3
            android:id="@+id/customView3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:usernameLabel="用户名"
            app:passwordLabel="密    码" />
    
    </LinearLayout>
    
    

    项目地址 https://github.com/webabcd/AndroidDemo
    作者 webabcd

  • 相关阅读:
    用小百合学python
    驱动对象 设备对象 设备栈 乱杂谈
    [转]很经典的http协议详解
    利用VMWare和WinDbg调试驱动程序
    GCC基础
    史上最著名的10个思想实验 (转)
    windows XP下驱动开发环境设置(DDK+VC6.0)
    守护进程
    驱动SYS开发总结
    ASP.NET学习笔记1
  • 原文地址:https://www.cnblogs.com/webabcd/p/android_view_custom_CustomView3Demo.html
Copyright © 2011-2022 走看看