一些android的日常笔记
1、textview文本:如果内容多的话,设置下面的一行代码,可以实现滑动。
text.setMovementMethod(ScrollingMovementMethod.getInstance());
2、
<TextView
android:id="@+id/Ccontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:maxEms="18"
android:singleLine="true"
android:ellipsize="end" />
这个是设置文本内容假如超过预设的值,则会以省略号显示。
3、布局文件转View对象
(1)View.inflate()
在Fragment中使用过,如
View view1=View.inflate(this,R.layout.viewpager1,null);
(2)使用getLayoutInflater()
View ly=getLayoutInflater().from(this).inflate(R.layout.viewpager1,null);
4、
/**
* 验证输入的身份证号是否合法
*/
public static boolean isLegalId(String id){
if (id.toUpperCase().matches("(^\\d{15}$)|(^\\d{17}([0-9]|X)$)")){
return true;
}else {
return false;
}
}
浙公网安备 33010602011771号