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

  • 相关阅读:
    每天一个Linux命令(3): cd
    每天一个Linux命令(2): ls
    scala学习笔记(2)
    jmeter性能测试 套路二
    selenium实战2 登陆博客园
    jmeter响应断言
    Python验证码通过pytesser识别
    selenium实战学习第一课
    appium的webdriver执行swipe
    APPIUM 输入中文 之套路
  • 原文地址:https://www.cnblogs.com/webabcd/p/android_view_custom_CustomView3Demo.html
Copyright © 2011-2022 走看看