{"id":194,"date":"2014-05-24T17:28:05","date_gmt":"2014-05-24T09:28:05","guid":{"rendered":"http:\/\/weitaoc.com\/?p=194"},"modified":"2019-09-27T14:17:52","modified_gmt":"2019-09-27T06:17:52","slug":"android%e5%8a%a0%e8%bd%bd%e4%b8%ad%e5%af%b9%e8%af%9d%e6%a1%86%e5%be%aa%e7%8e%af%e9%80%8f%e6%98%8e","status":"publish","type":"post","link":"http:\/\/weitaoc.com\/?p=194","title":{"rendered":"android\u52a0\u8f7d\u4e2d\u5bf9\u8bdd\u6846,\u5faa\u73af,\u900f\u660e"},"content":{"rendered":"<p>1\u3001\u81ea\u5b9a\u4e49\u5bf9\u8bdd\u6846<\/p>\n<div class=\"codecolorer-container java geshi\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<br \/>50<br \/><\/div><\/td><td><div class=\"java codecolorer\" style=\"white-space:nowrap\"><span style=\"color: #000000; font-weight: bold;\">public<\/span> <span style=\"color: #000000; font-weight: bold;\">class<\/span> HkDialogLoading <span style=\"color: #000000; font-weight: bold;\">extends<\/span> <span style=\"color: #003399;\">Dialog<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n<span style=\"color: #003399;\">Context<\/span> context<span style=\"color: #339933;\">;<\/span><br \/>\n<br \/>\nImageView vLoading<span style=\"color: #339933;\">;<\/span> <span style=\"color: #666666; font-style: italic;\">\/\/ \u5706\u578b\u8fdb\u5ea6\u6761<\/span><br \/>\nAnimation anim<span style=\"color: #339933;\">;<\/span><span style=\"color: #666666; font-style: italic;\">\/\/ \u52a8\u753b<\/span><br \/>\n<br \/>\n<span style=\"color: #000000; font-weight: bold;\">public<\/span> HkDialogLoading<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #003399;\">Context<\/span> context<span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">super<\/span><span style=\"color: #009900;\">&#40;<\/span>context, R.<span style=\"color: #006633;\">style<\/span>.<span style=\"color: #006633;\">HKDialogLoading<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">this<\/span>.<span style=\"color: #006633;\">context<\/span> <span style=\"color: #339933;\">=<\/span> context<span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\n<br \/>\n<span style=\"color: #000000; font-weight: bold;\">public<\/span> <span style=\"color: #000066; font-weight: bold;\">void<\/span> onCreate<span style=\"color: #009900;\">&#40;<\/span>Bundle savedInstanceState<span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\nrequestWindowFeature<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #003399;\">Window<\/span>.<span style=\"color: #006633;\">FEATURE_NO_TITLE<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nrequestWindowFeature<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #003399;\">Window<\/span>.<span style=\"color: #006633;\">PROGRESS_VISIBILITY_ON<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">super<\/span>.<span style=\"color: #006633;\">onCreate<\/span><span style=\"color: #009900;\">&#40;<\/span>savedInstanceState<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<br \/>\nanim <span style=\"color: #339933;\">=<\/span> AnimationUtils.<span style=\"color: #006633;\">loadAnimation<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000000; font-weight: bold;\">this<\/span>.<span style=\"color: #006633;\">getContext<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span>,<br \/>\nR.<span style=\"color: #006633;\">anim<\/span>.<span style=\"color: #006633;\">rotate_repeat<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nanim.<span style=\"color: #006633;\">setInterpolator<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000000; font-weight: bold;\">new<\/span> LinearInterpolator<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<br \/>\nvLoading <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000000; font-weight: bold;\">new<\/span> ImageView<span style=\"color: #009900;\">&#40;<\/span>context<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nvLoading.<span style=\"color: #006633;\">setImageResource<\/span><span style=\"color: #009900;\">&#40;<\/span>R.<span style=\"color: #006633;\">drawable<\/span>.<span style=\"color: #006633;\">loading_icon<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><span style=\"color: #666666; font-style: italic;\">\/\/ \u52a0\u8f7d\u4e2d\u7684\u56fe\u7247,\u5efa\u8bae\u5706\u5f62\u7684<\/span><br \/>\n<br \/>\n<span style=\"color: #666666; font-style: italic;\">\/\/ \u5e03\u5c40<\/span><br \/>\nFrameLayout.<span style=\"color: #006633;\">LayoutParams<\/span> lp <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000000; font-weight: bold;\">new<\/span> FrameLayout.<span style=\"color: #006633;\">LayoutParams<\/span><span style=\"color: #009900;\">&#40;<\/span><br \/>\nFrameLayout.<span style=\"color: #006633;\">LayoutParams<\/span>.<span style=\"color: #006633;\">MATCH_PARENT<\/span>,<br \/>\nFrameLayout.<span style=\"color: #006633;\">LayoutParams<\/span>.<span style=\"color: #006633;\">WRAP_CONTENT<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nlp.<span style=\"color: #006633;\">gravity<\/span> <span style=\"color: #339933;\">=<\/span> Gravity.<span style=\"color: #006633;\">CENTER<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<br \/>\naddContentView<span style=\"color: #009900;\">&#40;<\/span>vLoading, lp<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<br \/>\nsetCanceledOnTouchOutside<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000066; font-weight: bold;\">false<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\n<br \/>\n@Override<br \/>\n<span style=\"color: #000000; font-weight: bold;\">public<\/span> <span style=\"color: #000066; font-weight: bold;\">boolean<\/span> onKeyDown<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000066; font-weight: bold;\">int<\/span> keyCode, <span style=\"color: #003399;\">KeyEvent<\/span> event<span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">if<\/span> <span style=\"color: #009900;\">&#40;<\/span>keyCode <span style=\"color: #339933;\">==<\/span> <span style=\"color: #003399;\">KeyEvent<\/span>.<span style=\"color: #006633;\">KEYCODE_BACK<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n<span style=\"color: #666666; font-style: italic;\">\/\/ \u6309\u4e0b\u4e86\u952e\u76d8\u4e0a\u8fd4\u56de\u6309\u94ae<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">this<\/span>.<span style=\"color: #006633;\">hide<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">return<\/span> <span style=\"color: #000066; font-weight: bold;\">true<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">return<\/span> <span style=\"color: #000066; font-weight: bold;\">false<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\n<br \/>\n@Override<br \/>\n<span style=\"color: #000000; font-weight: bold;\">public<\/span> <span style=\"color: #000066; font-weight: bold;\">void<\/span> show<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">super<\/span>.<span style=\"color: #006633;\">show<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nvLoading.<span style=\"color: #006633;\">startAnimation<\/span><span style=\"color: #009900;\">&#40;<\/span>anim<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>2\u3001\u7528\u5230\u7684\u52a8\u753b\u6587\u4ef6rotate_repeat\u00a0(\u5728res\/anim\u76ee\u5f55\u4e0b\u9762\u5efa\u6587\u4ef6rotate_repeat.xml)<\/p>\n<div class=\"codecolorer-container xml geshi\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/><\/div><\/td><td><div class=\"xml codecolorer\" style=\"white-space:nowrap\"><span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;?xml<\/span> <span style=\"color: #000066;\">version<\/span>=<span style=\"color: #ff0000;\">&quot;1.0&quot;<\/span> <span style=\"color: #000066;\">encoding<\/span>=<span style=\"color: #ff0000;\">&quot;utf-8&quot;<\/span><span style=\"color: #000000; font-weight: bold;\">?&gt;<\/span><\/span>;<br \/>\n<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;set<\/span> <span style=\"color: #000066;\">xmlns:android<\/span>=<span style=\"color: #ff0000;\">&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;<\/span><\/span><br \/>\n<span style=\"color: #009900;\"><span style=\"color: #000066;\">android:interpolator<\/span>=<span style=\"color: #ff0000;\">&quot;@android:anim\/accelerate_interpolator&quot;<\/span> <span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><br \/>\n<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;rotate<\/span><\/span><br \/>\n<span style=\"color: #009900;\"><span style=\"color: #000066;\">android:duration<\/span>=<span style=\"color: #ff0000;\">&quot;1000&quot;<\/span><\/span><br \/>\n<span style=\"color: #009900;\"><span style=\"color: #000066;\">android:fromDegrees<\/span>=<span style=\"color: #ff0000;\">&quot;0&quot;<\/span><\/span><br \/>\n<span style=\"color: #009900;\"><span style=\"color: #000066;\">android:pivotX<\/span>=<span style=\"color: #ff0000;\">&quot;50%&quot;<\/span><\/span><br \/>\n<span style=\"color: #009900;\"><span style=\"color: #000066;\">android:pivotY<\/span>=<span style=\"color: #ff0000;\">&quot;50%&quot;<\/span><\/span><br \/>\n<span style=\"color: #009900;\"><span style=\"color: #000066;\">android:repeatCount<\/span>=<span style=\"color: #ff0000;\">&quot;100&quot;<\/span><\/span><br \/>\n<span style=\"color: #009900;\"><span style=\"color: #000066;\">android:repeatMode<\/span>=<span style=\"color: #ff0000;\">&quot;restart&quot;<\/span><\/span><br \/>\n<span style=\"color: #009900;\"><span style=\"color: #000066;\">android:toDegrees<\/span>=<span style=\"color: #ff0000;\">&quot;360&quot;<\/span> <span style=\"color: #000000; font-weight: bold;\">\/&gt;<\/span><\/span><br \/>\n<span style=\"color: #009900;\"><span style=\"color: #000000; font-weight: bold;\">&lt;\/set<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>3\u3001\u7528\u7684\u5230\u7684\u6837\u5f0f\u6587\u4ef6\u00a0(\u5728res\/values\u76ee\u5f55\u4e0b\u7684style.xml\u6587\u4ef6\u4e2d\u7684&lt;resources&gt;\u8282\u70b9\u4e0b\u6dfb\u52a0\u4e0b\u9762\u7684\u4ee3\u7801)<\/p>\n<div class=\"codecolorer-container xml geshi\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/><\/div><\/td><td><div class=\"xml codecolorer\" style=\"white-space:nowrap\"><span style=\"color: #000000; font-weight: bold;\">&lt;style<\/span> <span style=\"color: #000066;\">name<\/span>=<span style=\"color: #ff0000;\">&quot;HKDialogLoading&quot;<\/span> <span style=\"color: #000066;\">parent<\/span>=<span style=\"color: #ff0000;\">&quot;@android:style\/Theme.Dialog&quot;<\/span><span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">&lt;item<\/span> <span style=\"color: #000066;\">name<\/span>=<span style=\"color: #ff0000;\">&quot;android:windowFrame&quot;<\/span><span style=\"color: #000000; font-weight: bold;\">&gt;<\/span>@null<span style=\"color: #000000; font-weight: bold;\">&lt;\/item<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">&lt;item<\/span> <span style=\"color: #000066;\">name<\/span>=<span style=\"color: #ff0000;\">&quot;android:windowNoTitle&quot;<\/span><span style=\"color: #000000; font-weight: bold;\">&gt;<\/span>true<span style=\"color: #000000; font-weight: bold;\">&lt;\/item<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">&lt;item<\/span> <span style=\"color: #000066;\">name<\/span>=<span style=\"color: #ff0000;\">&quot;android:windowBackground&quot;<\/span><span style=\"color: #000000; font-weight: bold;\">&gt;<\/span>@color\/transparent<span style=\"color: #000000; font-weight: bold;\">&lt;\/item<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">&lt;item<\/span> <span style=\"color: #000066;\">name<\/span>=<span style=\"color: #ff0000;\">&quot;android:windowIsFloating&quot;<\/span><span style=\"color: #000000; font-weight: bold;\">&gt;<\/span>true<span style=\"color: #000000; font-weight: bold;\">&lt;\/item<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">&lt;item<\/span> <span style=\"color: #000066;\">name<\/span>=<span style=\"color: #ff0000;\">&quot;android:windowContentOverlay&quot;<\/span><span style=\"color: #000000; font-weight: bold;\">&gt;<\/span>@null<span style=\"color: #000000; font-weight: bold;\">&lt;\/item<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">&lt;\/style<span style=\"color: #000000; font-weight: bold;\">&gt;<\/span><\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>4\u3001\u8c03\u7528<\/p>\n<div class=\"codecolorer-container java geshi\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/><\/div><\/td><td><div class=\"java codecolorer\" style=\"white-space:nowrap\">dialogLoading <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000000; font-weight: bold;\">new<\/span> HKDialogLoading<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000000; font-weight: bold;\">this<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\ndialogLoading.<span style=\"color: #006633;\">show<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"color: #666666; font-style: italic;\">\/\/ \u663e\u793a\u52a0\u8f7d\u4e2d\u5bf9\u8bdd\u6846<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p><a href=\"http:\/\/weitaoc.com\/archives\/188\/1-2\" rel=\"attachment wp-att-189\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-189\" alt=\"1\" src=\"http:\/\/weitaoc.com\/wp-content\/uploads\/2014\/05\/1.jpg\" width=\"293\" height=\"220\" \/><\/a><\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"http:\/\/weitaoc.com\">\u8ff7\u8def\u7684\u8001\u9f20<\/a> &raquo; <a href=\"http:\/\/weitaoc.com\/?p=194\">android\u52a0\u8f7d\u4e2d\u5bf9\u8bdd\u6846,\u5faa\u73af,\u900f\u660e<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>1\u3001\u81ea\u5b9a\u4e49\u5bf9\u8bdd\u6846 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950public class HkDialogLoad [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58,4],"tags":[55],"class_list":["post-194","post","type-post","status-publish","format-standard","hentry","category-other","category-technology","tag-android"],"views":5874,"_links":{"self":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts\/194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=194"}],"version-history":[{"count":1,"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts\/194\/revisions"}],"predecessor-version":[{"id":468,"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts\/194\/revisions\/468"}],"wp:attachment":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=194"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}