暂无个人介绍
那你为什么要停止呢,留着不就行了
xml文件中的控件属性中添加这一条:android:maxLength="10",不要添加 android:singleLine="true"
public class MainActivity1 extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ll);
MySurfaceView sv = (MySurfaceView)findViewById(R.id.sv);
TextView tv = (TextView)findViewById(R.id.tv);
sv.setCallBack(new CallBack(){//设置回调接口实现类
@Override
public void setTextView(String str) {
tv.setText(str);//如果是在thread线程中调用的,这里包装一层handle再更新textview的值
}
})
}
interface CallBack{//定义一个回调接口
public void setTextView(String str);
}
}
class MySurfaceView extends SurfaceView{
private CallBack callBack = null;
public MySurfaceView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public void setCallBack(CallBack cb){//设置回调接口
this.callBack = cb;
}
public void show(String str){//回调显示
if(this.callBack!=null) this.callBack.setTextView(str);
}
}
读取
`
Typeface customFont = Typeface.createFromAsset(this.getAssets(), "fonts/YourCustomFont.ttf");
`
使用:
import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.TextPaint;
import android.text.style.TypefaceSpan;
public class CustomTypefaceSpan extends TypefaceSpan {
private final Typeface newType;
public CustomTypefaceSpan(String family, Typeface type) {
super(family);
newType = type;
}
@Override
public void updateDrawState(TextPaint ds) {
applyCustomTypeFace(ds, newType);
}
@Override
public void updateMeasureState(TextPaint paint) {
applyCustomTypeFace(paint, newType);
}
private static void applyCustomTypeFace(Paint paint, Typeface tf) {
int oldStyle;
Typeface old = paint.getTypeface();
if (old == null) {
oldStyle = 0;
} else {
oldStyle = old.getStyle();
}
int fake = oldStyle & ~tf.getStyle();
if ((fake & Typeface.BOLD) != 0) {
paint.setFakeBoldText(true);
}
if ((fake & Typeface.ITALIC) != 0) {
paint.setTextSkewX(-0.25f);
}
paint.setTypeface(tf);
}
}