2 Star 2 Fork 2

CHINASOFT_OHOS / BankCardFormat

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 2.86 KB
一键复制 编辑 原始数据 按行查看 历史
251309-lirui 提交于 2021-09-30 17:20 . 版本更新

BankCardFormat

项目介绍

  • 项目名称:BankCardFormat
  • 所属系列:openharmony的第三方组件适配移植
  • 功能:自动格式化银行卡号的TextField,每四位增加一个空格,并根据银行卡号判断该银行卡归属的银行
  • 项目移植状态:主功能完成
  • 调用差异:无
  • 开发版本:sdk6,DevEco Studio 2.2 Beta1
  • 基线版本: Release Tags 1.0.3

效果演示

安装教程

1.在项目根目录下的build.gradle文件中,

allprojects {
   repositories {
       maven {
           url 'https://s01.oss.sonatype.org/content/repositories/releases/'
       }
   }
}

2.在entry模块的build.gradle文件中,

dependencies {
   implementation('com.gitee.chinasoft_ohos:BankCardFormat:1.0.0')
   ......  
}

使用说明

组件主要由TextField控件和检索 TextWatcher组成。

原开源项目重写TextField,现在openharmony项目重写DependentLayout包含TextField的组合控件。

XML中添加自定义控件:

<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
    xmlns:ohos="http://schemas.huawei.com/res/ohos"
    ohos:height="match_parent"
    ohos:width="match_parent"
    ohos:orientation="vertical">

    <com.example.library.BandCardEditText
        ohos:id="$+id:et"
        ohos:height="match_content"
        ohos:width="match_parent"
        ohos:background_element="#f2f2f2"
        ohos:left_margin="15vp"
        ohos:top_margin="15vp"
        ohos:right_margin="15vp"
        ohos:padding="10vp"
        ohos:text="1020332121012012142"
        ohos:text_alignment="vertical_center"
        ohos:text_size="18fp"
        ohos:text_input_type="pattern_number"/>

    <Text
        ohos:id="$+id:text"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:background_element="$graphic:background_ability_main"
        ohos:left_margin="15vp"
        ohos:right_margin="15vp"
        ohos:text="所属银行:"
        ohos:multiple_lines="true"
        ohos:text_color="#666666"
        ohos:text_size="14fp"/>
</DirectionalLayout>

输入控件加入自动检索和格式化功能,并且在输入信息后自动格式化和检索所属信息进行显示:

BandCardEditText editText = (BandCardEditText) findComponentById(ResourceTable.Id_et);
     editText.setBankCardListener(new BankCardListener() {
    
         @Override
         public void success(String name) {
             tv.setText("所属银行:" + name);
         }
    
         @Override
         public void failure() {
             tv.setText("所属银行:");
         }
     });

测试信息

CodeCheck代码测试无异常

CloudTest代码测试无异常

病毒安全检测通过

当前版本demo功能与原组件基本无差异

版本迭代

  • 1.0.0

版权和许可信息

  • Apache License
1
https://gitee.com/chinasoft_ohos/BankCardFormat.git
git@gitee.com:chinasoft_ohos/BankCardFormat.git
chinasoft_ohos
BankCardFormat
BankCardFormat
master

搜索帮助