搜索
您的当前位置:首页正文

《Android》Lesson21-广播+SharedPrefe

来源:二三娱乐

Week12  2016/11/29上午1-4节

一、复习上节课内容

二、实现强制下线功能

1、TableLayout+LoginActivity

(1)设置行间距

android:lineSpacingExtra设置行间距,如”3dp”。

android:lineSpacingMultiplier设置行间距的倍数,如”1.2″。

(2)editText.requestFocus();获取焦点

(3)editText改变字体颜色

SpannableString ss = new SpannableString("你要写的内容");//设置0-2的字符颜色

ss.setSpan(new ForegroundColorSpan(Color.RED), 0, 2,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

txtInfo.setText(ss);

2、自定义Action

3、AlertDialog

dialogBuilder.setCancelable(false);

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

AlertDialog alertDialog=dialogBuilder.create();

alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

加权限

4、SharedPreferences

为什么使用SharedPreferences

使用方法

SharedPreferences保存对象

5、用SharedPreferences实现记住密码功能

6、学生错误

java.lang.RuntimeException: Unable to start receiver com.example.microsoft.androidlesson20loginoffline.ForceOfflineReceiver: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

原因:AlertDialog的包使用错误,应该用importandroid.app.AlertDialog;

Top