1、ProgressDialog的簡單應用:
ps:Thread.sleep不能放在主線程,否則的話ProgressDialog將不會顯示
2、AlertDialog的另一種應用:
代碼實現(xiàn):
定義array:res/values/Strings.xml
3、豐富界面顯示,Theme的使用
Theme_AlphaTheme定義在res/values/style.xml中
4、代碼片段:
設置EditText中的文字是明文還是密文顯示。
//明文
//密文
5、代碼片段:一般我們在國際化的時候,需要改變當前系統(tǒng)的語系。程序實現(xiàn)如下:
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();
ps:Thread.sleep不能放在主線程,否則的話ProgressDialog將不會顯示
2、AlertDialog的另一種應用:

代碼實現(xiàn):
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>
3、豐富界面顯示,Theme的使用
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());
5、代碼片段:一般我們在國際化的時候,需要改變當前系統(tǒng)的語系。程序實現(xiàn)如下:
Resources res = getResources(); Configuration conf = res.getConfiguration(); conf.locale = Locale.JAPAN; DisplayMetrics dm = new DisplayMetrics(); res.updateConfiguration(conf, dm);
更多文章、技術交流、商務合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
