跑马灯、短信与反射EditText

1.1、跑马灯功能

Android自带支持跑马灯功能,实现此功能需要设置已下属性:

 

android:ellipsize="marquee" // 必选,跑马灯样式

android:marqueeRepeatLimit="" // 可选()无限重复

android:singleLine="true" // 单行(多行则设置跑马灯无意义)

 

注:EditText有此属性,但不支持。TextView要实现跑马灯此功能需要获得焦点(可自定义一个类继承TextView,重新isFocused方法返回值设置为true即可

 

1.2、发送短信

添加权限--》 获取SmsManager ---》 发送短信(短信过长分条发送)

 

1、SEND_MSG;

2、SmsManager.getDefault();

3、List<String> ms = smsManager.divideMessage(待发送内容);

   sendTextMessage(手机号, 服务台地址, 发送内容, 是否发送成功,是否接收成功);

 

1.3EditText屏蔽输入法

反射源码内容:

void setNotShowSoftInputOnFocu(EditText editText) {

    if (android.os.Build.VERSION.SDK_INT <= 10) {  

     editText.setInputType(InputType.TYPE_NULL);  

          }else{

            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);  

            try {  

                Class<EditText> cls = EditText.class;  

                Method setShowSoftInputOnFocus;  

                setShowSoftInputOnFocus = cls.getMethod("setShowSoftInputOnFocus",  boolean.class);  

                setShowSoftInputOnFocus.setAccessible(true);  

                setShowSoftInputOnFocus.invoke(editText, false);  

            } catch (Exception e) {

                e.printStackTrace();  

            }   

        }  

}

 

转载于:https://www.cnblogs.com/xiaosw/p/3527436.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值