android源代码提示文本框还能输入多少个字符
1个回答
2017-05-10
展开全部
啥都不说,直接Demo:<?xml version="1.0" encoding="utf-8"?>
<mx:Application creationComplete="init()" xmlns:mx=" /2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.TextInput;
import mx.controls.Alert;
//限制输入框输入个数
private static var inputNum:Number = 5;
internal function inputHandler(event:Event):void{
var input:TextInput = event.target as TextInput;
var text:String = input.text;
if(text.length > inputNum){
Alert.show("文本框只能输入个" + inputNum + "字符");
input.text = text.substr(0,inputNum);
}
}
]]>
</mx:Script>
<mx:TextInput x="208" y="126" change="inputHandler(event)"/>
</mx:Application>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询