【Android 功能库】1,醍醐灌顶
<content>1. 修复一些已知 BUG</content>
<content>2. 优化一些卡顿项</content>
<content>3. 优化性能</content>
<content>4. 增加更新公告</content>
<content>1. 修复一些已知 BUG</content>
<content>2. 优化一些卡顿项</content>
<content>3. 优化性能</content>
<content>4. 增加更新公告</content>
</contents>
<flag>1</flag>
</updateInfo>
[](
)2.修改 AlertDialog 的样式(styles.xml)
<style name="MyDialogStyle" parent="Base.Theme.AppCompat.Light.Dialog">
<item name="android:windowAnimationStyle">@style/Base.Animation.AppCompat.Dialog</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:background">@color/color_bg</item>
<item name="android:textColor">@color/text</item>
<item name="android:textSize">30sp</item>
<item name="android:textColorPrimary">@color/colorGreenLess</item>
</style>
[](
)3.更新信息弹框的方法
/**
add by xiaoz 10.17 更新信息弹框
<?xml version="1.0" encoding="UTF-8"?>
<updateInfo>
<title>更新信息</title>
<contents>
</contents>
1 为弹框 0 为不弹
<flag>1</flag>
</updateInfo>
@return
*/
private void alertUpdateInfoDialog() {
AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this,R.style.MyDialogStyle);
//读取外部储存的 newapp 文件夹下的 update.xml
String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/newapp/updateInfo.xml";
File file = new File(path);
try {
Document doc = (new SAXBuilder()).build(file);
Element root = doc.getRootElement();
System.out.println("========================"+root.getChildText("title"));
dialog.setTitle(root.getChildText("title"));
List children = root.getChild("contents").getChildren("content");
System.out.println("========
=============="+children.size());
StringBuffer sb = new StringBuffer();
for (int i = 0; i < children.size(); i++) {
Element element = (Element) children.get(i);
String content = element.getText();
System.out.println("================="+content);
if (content.trim().length() != 0) {
sb.append(content+"\n");
}
}
dialog.setMessage(sb.toString());
System.out.println("======================"+root.getChildText("flag"));
dialog.setPositiveButton("不再提示", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
root.getChild("flag").setText("0");
//保存不再弹框的设置
saveXML(doc);
}
});
System.out.println("======================"+root.getChildText("flag"));
if ("1".equals(root.getChildText("flag"))) {
AlertDialog alertDialog = dialog.show();
//设置 Dialog 的高宽度(屏幕大小的一半),按钮文字大小
WindowManager m = getWindowManager();
Display d = m.getDefaultDisplay();
WindowManager.LayoutParams p = alertDialog.getWindow().getAttributes();
评论