1.ºÎνUIỊ̈߳ºÖ÷Òª¸ºÔð½çÃæµÄÏìÓ¦ÒÔ¼°»æÖƽçÃæÔªËØ¡£
?
ͨ¹ýSWT±à³ÌµÄÒ»¸öСÀý×Ó˵Ã÷һϣº
ÒÔÏ´úÂ룬±à¹ýSWTÓ¦ÓóÌÐòµÄ¶ÁÕß»á·Ç³£ÊìϤ¡£ËüÒ»°ã³öÏÖÔÚmainº¯ÊýµÄ½áβ¡£ÏÂÃæÀ´×Ðϸ·ÖÎöÒ»ÏÂËüµÄÏêϸÇé¿ö¡£
//µ±´°¿ÚδÊÍ·Åʱwhile (!shell.isDisposed()) { //Èç¹ûdisplay¶ÔÏóʼþ¶ÓÁÐÖÐûÓÐÁ˵ȴýµÄʼþ£¬¾ÍÈøÃÏ߳̽øÈëµÈ´ý״̬ if (!display.readAndDispatch()) display.sleep();}
?
ÉÏÃæµÄ³ÌÐòʵ¼ÊÉϾÍÊÇÎÒÃÇUIÏ̵߳Ĵ¦ÀíÂß¼£ºµ±³ÌÐòÆô¶¯ºó£¬UIÏ̻߳á¶ÁȡʼþµÈ´ý¶ÓÁУ¬¿´ÓÐûÓÐʼþµÈ´ý´¦Àí¡£Èç¹ûÓУ¬Ëü»á½øÐÐÏàÓ¦´¦Àí£¬Èç¹ûûÓÐËü»á½øÈë˯Ãß״̬¡£Èç¹ûÓÐеÄʼþµ½À´£¬ËüÓֻᱻ»½ÐÑ£¬½øÐд¦Àí¡£UIÏß³ÌËùÐèÒª´¦ÀíµÄʼþ°üÀ¨Óû§µÄÊó±êºÍ¼üÅ̲Ù×÷ʼþ£¬²Ù×÷ϵͳ»ò³ÌÐòÖз¢³öµÄ»æÖÆʼþ¡£Ò»°ãÀ´Ëµ£¬´¦ÀíʼþµÄ¹ý³ÌÒ²¾ÍÊÇÏìÓ¦Óû§²Ù×÷µÄ¹ý³Ì¡£
Ò»¸öºÃµÄ×ÀÃæÓ¦ÓóÌÐòÐèÒª¶ÔÓû§µÄ²Ù×÷×÷³ö×î¿ìµÄÏìÓ¦£¬Ò²¾ÍÊÇ˵ÎÒÃǵÄUIÏ̱߳ØÐ뾡¿ìµÄ´¦Àí¸÷ÖÖʼþ¡£´ÓÎÒÃdzÌÐòµÄ½Ç¶ÈÀ´Ëµ£¬ÔÚUIÏß³ÌÖÐÎÒÃDz»ÄܽøÐдóÁ¿µÄ¼ÆËã»òÕߵȴý£¬·ñÔòÓû§²Ù×÷ʼþµÃ²»µ½¼°Ê±µÄ´¦Àí¡£Í¨³££¬Èç¹ûÓдóÁ¿µÄ¼ÆËã»òÕßÐèÒª³¤Ê±¼äµÈ´ý£¨ÀýÈç½øÐÐÍøÂç²Ù×÷»òÕßÊý¾Ý¿â²Ù×÷£©Ê±£¬ÎÒÃDZØÐ뽫ÕâЩ³¤Ê±¼ä´¦ÀíµÄ³ÌÐòµ¥¶À¿ª±Ù³öÒ»¸öÏß ³ÌÀ´Ö´ÐС£ÕâÑùËäÈ»ºǫ́ÔËÐÐ×ųÌÐò£¬µ«Ò²²»»áÓ°Ïì½çÃæÉϵIJÙ×÷¡£
³ýÖ÷Ïß³ÌÖ®ÍâµÄËùÓÐÏ̶߳¼ÊÇ·ÇUIÏ̡߳£?
?
2. ϵͳÖжÔ×ÖÌåÀàÐ͵Äת»»´¦Àí·½·¨£º
public static float applyDimension(int unit, float value, DisplayMetrics metrics) { switch (unit) { case COMPLEX_UNIT_PX: return value; case COMPLEX_UNIT_DIP: return value * metrics.density; case COMPLEX_UNIT_SP: return value * metrics.scaledDensity; case COMPLEX_UNIT_PT: return value * metrics.xdpi * (1.0f/72); case COMPLEX_UNIT_IN: return value * metrics.xdpi; case COMPLEX_UNIT_MM: return value * metrics.xdpi * (1.0f/25.4f); } return 0; }
?
3.´úÂëÉèÖÿؼþµÄÍâ±ß¾à£º
?
ÔÚAndroidµÄ²¼¾ÖÎļþÖУ¬¿ÉÒÔÉèÖÃMargginÊôÐÔÖ¸¶¨Íâ±ß¾à£¬
?
<ImageView android:layout_margin="5dip" android:src="@drawable/image" />
??
µ«ÊǿؼþÔÚ´úÂëÖÐûÓÐsetMargginÖ®ÀàµÄ·½·¨¿ÉÒÔʹÓᣲ»¹ýLinearLayout . LayoutParamsÖÐÓÐsetMarggin·½·¨£¬
ËùÒÔ¿ÉÒÔʵÏÖΪ£º
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);lp.setMargins(left, top, right, bottom);imageView.setLayoutParams(lp);
?
?4.Android Canvas»æͼ¿¹¾â³Ý½â¾ö·½·¨£º
?
ÏÂÃæµÄ·½·¨Ã²ËÆÐв»Í¨£¬¿´ÕâÀï°É£ºhttp://emmet1988.iteye.com/blog/1144439
?
? ¶ÔÓÚAndroidÀ´ËµCanvasÒ»°ã´óÁ¿ÓÃÓÚ×Ô¶¨ÒåViewºÍÓÎÏ·¿ª·¢ÖУ¬¶ÔÓÚͼÐεĻù´¡»æÖÆÀ࣬ÌṩµÄdrawText¡¢drawBitmapÒÔ¼°drawCircle¶¼ÐèÒª¿¹¾â³Ý´¦Àí²ÅÄÜÈÃÈËÂúÒ⣬ÏÂÃæAndroid123½«ËûÃÇ·ÖΪÁ½´óÖÖÇé¿ö¡£
?Ò»¡¢°üº¬Paint²ÎÊýÇé¿öʱ£¬¶ÔÓÚdrawText¡¢drawBitmapÕâÑùµÄ·½·¨£¬Ò»°ã×îºóÒ»¸ö²ÎÊýΪPaint¶ÔÏó£¬Paint¶ÔÏóÒ»°ãÓÃÓÚÉèÖñÊË¢ÑÕÉ«ºÍ´óС£¬Í¬Ê±°üº¬ÁË¿¹¾â³ÝµÄ·½·¨£¬±ÈÈç˵objPaint.setAntiAlias(true);? Õâ¸ö·½·¨Ö´Ðк󼴿ÉÓбȽÏÃ÷ÏԵĸÄÉÆ¡£
?¶þ¡¢²¿·Ö·½·¨Ã»ÓÐPaint²ÎÊý£¬±ÈÈç˵setDrawFilterÕâ¸ö·½·¨£¬ËüµÄ²ÎÊýÖ»ÓÐ PaintFlagsDrawFilter¶ÔÏó£¬ÎÒÃÇ×Ô¼º¹¹ÔìÒ»¸öеĶÔÏ󣬱ÈÈç˵new PaintFlagsDrawFilter(0,Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG)ÕâÑù¾Í¹ýÂËÆ÷¿ÉÒÔÈÃÎı¾ºÍλͼ¾¹ýÔ²»¬´¦Àí¡£
?
5.Android xliffºÍ×Ö·û´®×ÊÔ´?£º
ºÜ¶àAndroid¿ª·¢Õß¿ÉÄܻᷢÏÖ²¿·Ö×ÊÔ´×Ö·û´®ÔÚ/res/values/string.xmlÖаüº¬ÓÐÀàËÆxliffµÄ½Úµã£¬XliffÊÇXML Localization Interchange File Format µÄËõд£¬ÖÐÎÄÃûΪXML±¾µØ»¯Êý¾Ý½»»»¸ñʽ£¬¶ÔÓÚÔÚAndroidµÄ×ÊÔ´×Ö·û´®ÖУ¬¿ÉÄÜ»áÓÐÀàËÆÏÂÃæµÄ <xliff:g id="cwj">%1$s</xliff:g> ÕâÀidÎÒÃÇ¿ÉÒÔËæ±ã¶¨Ò壬ºóÃæµÄ%1$sÓеãÏñC#ÖеÄ×Ö·û´®¸ñʽ»¯±êÖ¾£¬ÕâÀï1%±íʾÕâÊǵÚÒ»¸ö¿ÉÌæ»»Á¿£¬Èç¹ûÒ»¸öStringÖÐÓжà¸öÐèÒªÌæ»»µÄ±äÁ¿£¬¿ÉÒÔΪ
? <string name="info">¿ª·¢Õß<xliff:g id="name">%1$s</xliff:g> À´×Ô?<xliff:g id="company">%2$s</xliff:g> ¹«Ë¾</string>
? ¶ÔÓÚÉÏÃæµÄ×Ö·û´®£¬ÔÚ¹¤³ÌÖÐÎÒÃÇ¿ÉÒÔʹÓÃString strInfo=getResources().getString(R.string.info,"cwj","android123"); À´Æ´½Ó£¬·µ»ØÒ»¸öеÄ×Ö·û´®strInfoÖС£
?
2 androidÅжϿì½Ý·½Ê½ÊÇ·ñÒѾ´´½¨µÄ·½·¨ http://elvwong.iteye.com/blog/859800
3 ListViewµÄ¸÷ÖÖʹÓ÷½·¨ http://www.vogella.de/articles/AndroidListView/article.html
4 Context.startService()ÓëContext.bindService()Çø±ð http://blog.csdn.net/tiewantn/article/details/6021022
5 Android ÖÐµÄ Service È«Ãæ×ܽá http://blog.csdn.net/chenlaic/article/details/6143235
6 TextWatcher¼à¿ØEditTextÖеÄÊäÈëÄÚÈݲ¢ÏÞÖÆÆäÊäÈë×Ö·û¸öÊý http://www.cnblogs.com/cat-fang/archive/2011/04/12/2013428.html
7 androidºáÊúÆÁÇл»²»ÖØÆôactivity?? http://crazier9527.iteye.com/blog/918618
8 Àí½âActivity http://blog.csdn.net/richway2010/article/details/6572708
9 android°æ±¾×Ô¶¯Éý¼¶´úÂë http://blog.csdn.net/deaboway/article/details/6431943
10 AndroidÓ¦ÓÃÉý¼¶¹¹ÏëºÍÒªµã×ܽá http://blog.csdn.net/richway2010/article/details/6408258
11 android ÓôúÂëÉèÖÃmarginÊôÐÔ£¬textView¼Ó´Ö http://blog.csdn.net/cenlulu/article/details/6336322
?
1.ÈÃÒ»¸öͼƬ͸Ã÷£º
- Bitmap?buffer?=?Bitmap.createBitmap(width,?height,?Bitmap.Config.ARGB_4444);buffer.eraseColor(Color.TRANSPARENT);???
2.Ö±½Ó·¢ËÍÓʼþ£º
- Intent?intent?=?new?Intent(Intent.ACTION_SENDTO,??Uri?.fromParts("mailto",?"[email protected]",?null));? ??
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);? ??
- context.startActivity(intent);???
3.³ÌÐò¿ØÖÆÆÁÄ»±äÁÁ£º
- WindowManager.LayoutParams?lp?=?getWindow().getAttributes();? ??
- lp.screenBrightness?=?100?/?100.0f;? ??
- getWindow().setAttributes(lp);??
4.¹ýÂËÌض¨Îı¾
- Filter?filter?=?myAdapter.getFilter();? ??
- filter.filter(mySearchText);???
5.scrollView scrollֹͣʼþ
- setOnScrollListener(new?OnScrollListener(){???? ??
- public?void?onScroll(AbsListView?view,?int?firstVisibleItem,?int?visibleItemCount,?int?totalItemCount)?{?????? ??
- //?TODO?Auto-generated?method?stub????}???? ??
- public?void?onScrollStateChanged(AbsListView?view,?int?scrollState)?{?????? ??
- //?TODO?Auto-generated?method?stub?????? ??
- if(scrollState?==?0)?Log.i("a",?"scrolling?stopped...");????}??});}???
6. ¶ÔÓÚÌض¨µÄ³ÌÐò ·¢ÆðÒ»¸ö¹ØÁª¹©´ò¿ª
- Bitmap?bmp?=?getImageBitmap(jpg);? ??
- String?path?=?getFilesDir().getAbsolutePath()?+?"/test.png";? ??
- File?file?=?new?File(path);? ??
- FileOutputStream?fos?=?new?FileOutputStream(file);? ??
- bmp.compress(?CompressFormat.PNG,?100,?fos?);? ??
- ??fos.close();? ??
- ?? ??
- ???Intent?intent?=?new?Intent();? ??
- ???intent.setAction(android?.content.Intent.ACTION_VIEW);? ??
- ???intent.setDataAndType(Uri?.fromFile(new?File(path)),?"image/png");? ??
- ???startActivity(intent);? ??
- ¶ÔÓÚͼƬÉϱߵIJ»ÊÊÓÃË÷Òý¸ñʽ»á³ö´í¡£? ??
- Intent?intent?=?new?Intent();?? ??
- intent.setAction(android?.content.Intent.ACTION_VIEW);?? ??
- File?file?=?new?File("/sdcard/test.mp4");?? ??
- intent.setDataAndType(Uri?.fromFile(file),?"video/*");?? ??
- startActivity(intent);? ??
- ??
- Intent?intent?=?new?Intent();?? ??
- intent.setAction(android?.content.Intent.ACTION_VIEW);?? ??
- File?file?=?new?File("/sdcard/test.mp3");?? ??
- intent.setDataAndType(Uri?.fromFile(file),?"audio/*");?? ??
- startActivity(intent);???
7.ÉèÖÃÎı¾Íâ¹Û
- setTextAppearance(context,?android?.R.style.TextAppearance_Medium);? ??
- android?:textAppearance="?android?:attr/textAppearanceMedium"??
8.ÉèÖõ¥¶ÀµÄ·¢Æðģʽ£º
- <activity???????? ??
- ??android?:name=".ArtistActivity"???????? ??
- ??android?:label="Artist"???????? ??
- ??android?:launchMode="singleTop">???? ??
- ??</activity>? ??
- ??
- Intent?i?=?new?Intent();???????? ??
- ???i.putExtra(EXTRA_KEY_ARTIST,?id);??????? ??
- ????i.setClass(this,?ArtistActivity.class);???????? ??
- ????i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);??????? ??
- ?????startActivity(i);???
9.´´½¨Ò»¸öÔ²½ÇͼƬ
Õâ¸öµÄÖ÷ÒªÔÀíÆäʵ¾ÍÊÇÀûÓÃÕÚÕÖ£¬ÏÈ´´½¨Ò»¸öÔ²½Ç·½¿ò È»ºó½«Í¼Æ¬·ÅÔÚÏÂÃ棺
- Bitmap?myCoolBitmap?=?...?;? ??
- ??????int?w?=?myCoolBitmap.getWidth(),?h?=?myCoolBitmap.getHeight();? ??
- ??????Bitmap?rounder?=?Bitmap.createBitmap(w,h,Bitmap.Config.ARGB_8888);? ??
- ??????Canvas?canvas?=?new?Canvas(rounder);???? ??
- ??????Paint?xferPaint?=?new?Paint(Paint.ANTI_ALIAS_FLAG);? ??
- ??????xferPaint.setColor(Color.RED);? ??
- ??????canvas.drawRoundRect(new?RectF(0,0,w,h),?20.0f,?20.0f,?xferPaint);????? ??
- ??????xferPaint.setXfermode(new?PorterDuffXfermode(PorterDuff.Mode.DST_IN));???
- //È»ºóÄØʵÏÖ? ??
- canvas.drawBitmap(myCoolBitmap,?0,0,?null);? ??
- canvas.drawBitmap(rounder,?0,?0,?xferPaint);? ??
10.ÔÚnotification ÉϵÄiconÉϼÓÉÏÊý×Ö ¸øÈËÌáʾÓжàÉÙ¸öδ¶Á
- Notification?notification?=?new?Notification?(icon,?tickerText,?when);? ??
- notification?.number?=?4;???
11±³¾°½¥±ä£º
Ê×ÏȽ¨Á¢Îļþdrawable/shape.xml
- <?xml?version="1.0"?encoding="utf-8"?>? ??
- <shape?xmlns:android?="http://schemas.android?.com/apk/res/android?"?android?:shape="rectangle">? ??
- ????<gradient?android?:startColor="#FFFFFFFF"?android?:endColor="#FFFF0000"? ??
- ????????????android?:angle="270"/>? ??
- </shape>? ??
ÔÚ¸ÃÎļþÖÐÉèÖý¥±äµÄ¿ªÊ¼ÑÕÉ«(startColor)¡¢½áÊøÑÕÉ«(endColor)ºÍ½Ç¶È(angle)
½Ó×Å´´½¨Ò»¸öÖ÷Ìâvalues/style.xml
- <?xml?version="1.0"?encoding="utf-8"?>? ??
- <resources>? ??
- <style?name="NewTheme"?parent="android?:Theme">? ??
- <item?name="android?:background">@drawable/shape</item>? ??
- </style>? ??
- </resources>???
È»ºóÔÚAndroidManifest.xmlÎļþÖеÄapplication»òactivityÖÐÒýÈë¸ÃÖ÷Ìâ,Èç:
- <activity?android?:name=".ShapeDemo"?android?:theme="@style/NewTheme">? ??
¸Ã·½·¨Í¬ÑùÊÊÓÃÓڿؼþ
<?php xml version="1.0" ?>
?
<response>
<error>1</error>
<message>Invalid URL.</message>
</response>
12. ´¢´æÊý¾Ý µ±ÄãÔÚÒ»¸öʵÀýÖб£´æ¾²Ì¬Êý¾Ý£¬´ËʾÀý¹Ø±Õºó ÏÂÒ»¸öʵÀýÏëÒýÓà ¾²Ì¬Êý¾Ý¾Í»áΪnull£¬ÕâÀïÄرØÐëÖØдapplition
- public?class?MyApplication?extends?Application{???? ??
- ???private?String?thing?=?null;???? ??
- ???public?String?getThing(){???????? ??
- ?????return?thing;???? ??
- ?????}???? ??
- ?????public?void?setThing(?String?thing?){??????? ??
- ??????this.thing?=?thing;????}? ??
- ??????}? ??
- ??????public?class?MyActivity?extends?Activity?{???? ??
- ??????private?MyApplication?app;???? ??
- ??????public?void?onCreate(Bundle?savedInstanceState)?{???????? ??
- ??????super.onCreate(savedInstanceState);???????? ??
- ??????app?=?((MyApplication)getApplication());???????? ??
- ??????String?thing?=?app.getThing();???? ??
- ??????}? ??
- ??????}