Android寮€鍙?Android涓韩浠借瘉鍒ゆ柇鏄惁姝g‘

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android寮€鍙?Android涓韩浠借瘉鍒ゆ柇鏄惁姝g‘相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/klist' title='klist'>klist   textview   new   schema   渚濊禆   androi   version   ppp   contex   

绠€浠嬶細

褰撻渶瑕佺敤鎴疯緭鍏ヨ韩浠借瘉鍙风殑鏃跺€欙紝鍓嶇鍙互鍋氱畝鍗曠殑鏍¢獙锛岄伩鍏嶇敤杈撳叆韬唤璇佸彿閿欒銆?/p>

 

姝ラ涓€锛氬竷灞€鏂囦欢activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical">

 

    <EditText

        android:id="@+id/Card"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginLeft="10dp"

        android:digits="0123456789xX"

        android:hint="璇疯緭鍏ユ偍鐨勮韩浠借瘉鍙?

        android:inputType="number"

        android:maxLength="18"

        android:numeric="integer"

        android:singleLine="true"

        android:textSize="18sp" />

 

    <Button

        android:id="@+id/button1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="楠岃瘉杈撳叆鏄惁姝g‘" />

 

    <TextView

        android:id="@+id/isRight"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content" />

 

</LinearLayout>

 

姝ラ浜岋細MainActivity.java 涓荤晫闈?/p>

package com.huwan.checkidcarddemo;

 

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;

import android.widget.Toast;

import java.text.ParseException;

 

public class MainActivity extends AppCompatActivity {

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

 

        final EditText etCard = findViewById(R.id.Card);

        Button button1 = findViewById(R.id.button1);

        final TextView cardisRight = findViewById(R.id.isRight);

 

        button1.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                String idCardErrorInfo = "";

                try {

                    idCardErrorInfo = IDCard.IDCardValidate(etCard.getText().toString());

 

                    if (!"".equals(idCardErrorInfo)){

                        Toast.makeText(MainActivity.this,idCardErrorInfo,Toast.LENGTH_SHORT);

//                        CLToastUtil.showToast(context, idCardErrorInfo);

                        cardisRight.setText(idCardErrorInfo);

                    }else{

                        cardisRight.setText("姝g‘");

                    }

 

                } catch (ParseException e) {

                    e.printStackTrace();

                }

 

            }

        });

    }

}

 

姝ラ涓夛細渚濊禆浜嗗皝瑁呭ソ鐨処DCard.java鏂囦欢锛屽叿浣撳唴瀹硅涓嬭浇Demo鍚庢煡鐪嬨€?/p>

 

Demo鏍蜂緥涓嬭浇锛?a href="http://www.huwan.xin/Source/AppPackage/ZIP/Android/CheckIdCardDemo.rar">http://www.huwan.xin/Source/AppPackage/ZIP/Android/CheckIdCardDemo.rar

鏇村鍐呭璇疯闂細www.huwan.xin

 

以上是关于Android寮€鍙?Android涓韩浠借瘉鍒ゆ柇鏄惁姝g‘的主要内容,如果未能解决你的问题,请参考以下文章

iOS - SDK寮€鍙?涓嬮泦) 锛孲DK鍙戝竷鍒癈ocoapods

Android 寮€婧愭鏋?( 涓?) 浜嬩欢鎬荤嚎---EventBus

PyCharm | 寮€鍙戝伐鍏蜂笌Python鐨勫畬缇庣粨鍚堬紙闄勮棰戞暀绋嬶級

鐮佸啘鎵嬭涓⊿PARK鎬ц兘璋冧紭

寮虹儓鎺ㄨ崘5涓狥lutter閲嶇寮€婧愰」鐩紒