android 身份证号的4到11位用*显示怎么做
来源:互联网 发布:淘宝投诉电话是多少400 编辑:程序博客网 时间:2024/06/06 02:55
参考以下代码:
package com.sh.xy;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.view.View.OnClickListener;import android.view.Window;import android.widget.Button;import android.widget.EditText;import android.widget.Toast;public class MainActivity extends Activity {// 完整身份证String id = "323218200001010010";private EditText ed_id;private Button btn_show;private Button btn_show_to_edit;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_main);ed_id = (EditText) findViewById(R.id.ed_id);btn_show = (Button) findViewById(R.id.show_id);btn_show_to_edit = (Button) findViewById(R.id.show_id_to_edit);// 用于显示的加*身份证String show_id = id.substring(0, 3) + "********" + id.substring(11);ed_id.setText(show_id);btn_show.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {Toast.makeText(MainActivity.this, id, Toast.LENGTH_SHORT).show();}});btn_show_to_edit.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {ed_id.setText(id);}});}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {getMenuInflater().inflate(R.menu.main, menu);return true;}@Overridepublic boolean onOptionsItemSelected(MenuItem item) {int id = item.getItemId();if (id == R.id.action_settings) {return true;}return super.onOptionsItemSelected(item);}}
布局文件:
<LinearLayout xmlns:android="<a href="http://schemas.android.com/apk/res/android"" target="_blank">http://schemas.android.com/apk/res/android"</a> xmlns:tools="<a href="http://schemas.android.com/tools"" target="_blank">http://schemas.android.com/tools"</a> android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.sh.xy.MainActivity" > <include android:id="@+id/top" android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/layout_title_bar" /> <EditText android:id="@+id/ed_id" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="显示加*身份ID" /> <Button android:id="@+id/show_id" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="显示完整身份ID" /> <Button android:id="@+id/show_id_to_edit" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="将完整身份ID至编辑框" /></LinearLayout>
运行效果:
点击【显示得完整身份ID】按钮:
点击【将完整身份ID至编辑框】按钮:
0 0
- android 身份证号的4到11位用*显示怎么做
- Android手机wifi显示的开关Switch怎么做的
- 汇总15位身份证号和18位身份证号的区别
- java--18位身份证号最后一位(检验码)是怎么算出来的?
- 15位的身份证号转为18位
- 校验18位身份证号是否是有效的身份证号
- 在JSP页面,用人的18位身份证号显示其生日
- java-15位身份证号升级到18位
- 身份证号每一位号码的意义
- 身份证号第18位的计算
- 十五位的身份证号转为十八位的
- 十五位的身份证号转为十八位的
- 十五位的身份证号转为十八位的
- 十五位的身份证号转为十八位的
- 十五位的身份证号转为十八位的(c#)
- js身份证号码的校验,支持15位身份证号和18位身份证号
- 身份证号 15位与18位间的转换
- 将身份证号的一部分显示为“*”号
- HDU 2048 神、上帝以及老天爷(DP)
- Mysql 查看连接数,状态
- UIView常用的一些方法小记之setNeedsDisplay和setNeedsLayout
- linux的“自动化”
- Java并发编程类学习总结
- android 身份证号的4到11位用*显示怎么做
- 插入数据时含特殊字符的处理
- Java IO系列5 字节流之BufferedInputStream
- 剑指offer编程练习(Program2)
- C++函数模板和模板函数
- hdu acm 1827 Summer Holiday
- nodejs + express + ejs + mongodb本地环境安装及搭建
- xcode中的方法command+左键不能进行索引跳转的解决方法
- ios音量振动条