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