[color=red]1、ProgressDialog的简单应用:[/color]
[color=red]ps:Thread.sleep不能放在主线程,否则的话ProgressDialog将不会显示[/color]
[color=red]2、AlertDialog的另一种应用:[/color]
[img]http://dl.iteye.com/upload/attachment/506274/71381b08-2c90-3d60-954a-401bb7a9cad0.png[/img]
代码实现:
定义array:res/values/Strings.xml
[color=red]3、丰富界面显示,Theme的使用[/color]
Theme_AlphaTheme定义在res/values/style.xml中
4、代码片段:
设置EditText中的文字是明文还是密文显示。
//明文
//密文
[color=red]5、代码片段:一般我们在国际化的时候,需要改变当前系统的语系。程序实现如下:[/color]
ProgressDialog dialog = ProgressDialog.show(this, "hello", "are you sure???");
new Thread(){
public void run() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dialog.dismiss();
};
}.start();
[color=red]ps:Thread.sleep不能放在主线程,否则的话ProgressDialog将不会显示[/color]
[color=red]2、AlertDialog的另一种应用:[/color]
[img]http://dl.iteye.com/upload/attachment/506274/71381b08-2c90-3d60-954a-401bb7a9cad0.png[/img]
代码实现:
array = getResources().getStringArray(R.array.you_choice);
new AlertDialog.Builder(this).setTitle("请选择").setItems(array, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).create().show();
定义array:res/values/Strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World!</string>
<string name="app_name">Android_SDK_Sample</string>
<array name="you_choice">
<item>牛肉</item>
<item>米饭</item>
<item>豆角</item>
</array>
</resources>
[color=red]3、丰富界面显示,Theme的使用[/color]
setTheme(R.style.Theme_AlphaTheme);
setContentView(R.layout.ch3_19);
Theme_AlphaTheme定义在res/values/style.xml中
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="mystyle">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#EC9237</item>
<item name="android:fromAlpha">0.0</item>
<item name="android:toAlpha">0.0</item>
</style>
<style name="Theme" parent="android:Theme">
</style>
<style name="Theme.AlphaTheme">
<item name="android:background">#aaff00ff</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorForeground">@drawable/blue</item>
<item name="android:colorBackground">@drawable/pink</item>
</style>
</resources>
4、代码片段:
设置EditText中的文字是明文还是密文显示。
//明文
et.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
//密文
et.setTransformationMethod(PasswordTransformationMethod.getInstance());
[color=red]5、代码片段:一般我们在国际化的时候,需要改变当前系统的语系。程序实现如下:[/color]
Resources res = getResources();
Configuration conf = res.getConfiguration();
conf.locale = Locale.JAPAN;
DisplayMetrics dm = new DisplayMetrics();
res.updateConfiguration(conf, dm)
;