ã¯ããã«
Android Designã¨ãããã¼ã¸ãå ¬éãããããããAndroidã®ãã¶ã¤ã³ã¬ã¤ãã©ã¤ã³ãã¾ã¨ãã«ãªãã¤ã¤ããããã§ãããä¸ã§ãAction Bar | Android Developersã¯ãã¢ããªã®UIã®ä¸ã§ãæãéè¦ã«ãªããã¶ã¤ã³ãã¿ã¼ã³ã§ã¯ãªãã§ããããããããããã®Action Barã«é¢ããAPIã¯ãAndroid 3.0 (API level 11)ããããå©ç¨ã§ãã¾ããã
Androidã«ã¯ãæ°ããAPIãéå»ã®ãã¼ã¸ã§ã³ã§ãå©ç¨ã§ããããã«ããããã®Support Packageã¨ããã©ã¤ãã©ãªãåå¨ããã®ã§ãããæ®å¿µãªãããªããAction Barã«é¢ããAPIã¯å«ã¾ãã¦ãããSupport Packageã§Action Barãå®è£ ãããã¨ãã§ãã¾ããã
ActionBarSherlockã¨ã¯
ActionBarSherlockã¯ããã®åé¡ã解決ããããã«ãSupport Packageãæ¡å¼µãã¦Androidã®åãã¼ã¸ã§ã³ã®äºææ§ãä¿ã¡ãªããAction Barãå®è£ ã§ããã©ã¤ãã©ãªã§ããï¼Action Bar以å¤ã«ãããããã§ããããªã®ã§ããã¾ã è¦ããã¦ããªãã®ã§ä»æ¥ã¯Action Barã«ã¤ãã¦ã ããï¼
ãã¦ã³ãã¼ã
http://beta.abs.io/ ãããã¦ã³ãã¼ãã§ãã¾ããä»æ¥æç¹ã§ã¯RC1ãææ°ã§ããã3/7ã«æ£å¼ãªãªã¼ã¹ãããããã§ãã
ã©ã¤ãã©ãªããã¸ã§ã¯ã
ActionBarSherlockã¯ãEclipseã§Androidã©ã¤ãã©ãªããã¸ã§ã¯ãã¨ãã¦å©ç¨ãã¾ããã¾ããBuild TargetãAndroid 4.0(API Level 14)ã«ãªã£ã¦ããã®ã§ã¤ã³ã¹ãã¼ã«ãã¦ããªãå ´åã¯ãã¤ã³ã¹ãã¼ã«ãã¦ãã ããã
.zipããã¦ã³ãã¼ããã¦è§£åããããEclipseã§Androidããã¸ã§ã¯ããä½ãã¾ãã
ãProject Nameãã«é©å½ãªååãå
¥ãã¦ããCreate project from existing sourceããé¸ãã§ã解åãããã©ã«ãã®ä¸ã®library/ãã©ã«ããé¸ãã§ããNext >ããã¯ãªãã¯ãã¾ãã
ãAndroid 4.0ããé¸æãã¦ãFinishããã¯ãªãã¯ãã¾ãã
project.propertiesã§android.library=trueã«ãªã£ã¦ããã®ã§èªåçã«Androidã©ã¤ãã©ãªããã¸ã§ã¯ãã«ãªãã¾ãã
ActionBarSherlockã使ãå´ã®Androidããã¸ã§ã¯ã
ãProject Nameãã«é©å½ãªååãå ¥ãã¦ããNext >ããã¯ãªãã¯ãã¾ãã
ActionBarSherlockã¨ã®äºææ§ãèãã¦ä½¿ãå´ãAndroid 4.0(API Level 14)ã«ãã¾ãããAndroid 4.0ããé¸æãã¦ãNext >ããã¯ãªãã¯ãã¾ãã
ãPackage Nameããé©å½ã«å ¥ãã¦ãActivityã®ååãå¥ã«ãã®ã¾ã¾ã§ããããã§ããå人çã«æ°ã«ãªãã®ã§MainActivityã«ãã¦ããFinishããã¯ãªãã¯ãã¾ãã
ããã¸ã§ã¯ãã®Propertiesãéãã¦ãLibraryã®ãAddããã¯ãªãã¯ãã¦ãããã»ã©ä½æããActionBarSherlockã®Androidã©ã¤ãã©ãªããã¸ã§ã¯ããé¸æãã¾ããåç
§ãã¹ãæ°ã«ãªãå ´åã¯ãActionBarSherlockã解åãããã©ã«ãã®library/ãã©ã«ããé©å½ãªå ´æã«ç§»åãã¦ãã©ã«ãåããªãã¼ã ãããªããã¦ãã ããã
追å ã§ããããOKããã¯ãªãã¯ãã¾ãã
Activityã§
MainActivity.javaãéãã¦ãActivityãç¶æ¿ãã代ããã«SherlockActivityãç¶æ¿ãã¾ããã©ã¤ãã©ãªã®è¨å®ãæ£ããã§ãã¦ããã°Command+Shift+Oã§èªåã¤ã³ãã¼ãã§ããã¯ãã§ãã
ãã1ç¹ãActionBarSherlockã使ãå ´åã¯æ±ºãããããã¼ãã使ãå¿ è¦ãããã¾ããï¼ãã¶ã¤ã³ãããã«ã«ã¹ã¿ãã¤ãºãããå ´åã¯ãã¼ããç¶æ¿ãã¦ã¹ã¿ã¤ã«ãä¸æ¸ããããã¨ãã§ããã¨æãã¾ããï¼
ã¾ããsetTheme()ã¡ã½ããã§ãã¼ããã»ããããã®ã§ããããã®ã¡ã½ããã¯setContentView()ã¡ã½ãããããå ã«å¼ã³åºãå¿ è¦ãããã¾ãã
ã¨ãããã¨ã§ç·¨éå¾ã®ã³ã¼ãã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
package com.example.helloactionbar; import android.os.Bundle; import com.actionbarsherlock.app.SherlockActivity; public class MainActivity extends SherlockActivity { @Override public void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_Sherlock); super.onCreate(savedInstanceState); setContentView(R.layout.main); } }
ãªãããã¼ãã¯ä»¥ä¸ã®3ã¤ããé¸ã¶ãã¨ãã§ãã¾ããï¼ä»ã«ãNoActionBarãªã©ãããã¾ããå¿ è¦ã«å¿ãã¦é¸æãã¦ãã ãããï¼
Theme_Sherlock
Theme_Sherlock_Light
Theme_Sherlock_Light_DarkActionBar
Android 2.xã§ãã¤ã³ã¹ãã¼ã«ã§ããããã«
ãã®ã¾ã¾ã§ã¯Android 4.0ã«ããã¤ã³ã¹ãã¼ã«ã§ãã¾ãããAndroid 2.xã§ãã¤ã³ã¹ãã¼ã«ã§ããããã«AndroidManifest.xmlã§minSdkVersionãæå®ãã¾ãã
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14"/>
ããã§Android 2.1以ä¸ã§ã¤ã³ã¹ãã¼ã«ã§ãã¾ãããã¡ãã2.3以ä¸ã§ç¸ã£ã¦ãããã¨æãã¾ãã
ã¨ãããã¨ã§Android 2.1ã®ã¨ãã¥ã¬ã¼ã¿ã§ãAction Barã表示ã§ãã¾ãããã£ã¨ï¼
ãã®ãã¨ã¯
ãã¦ã³ãã¼ããã.zipã解åãããã©ã«ãã®samples/demos/ã«ãã¢ã¢ããªãããã®ã§ãããè¦ãã®ãä¸çªç¢ºå®ã§éããã¨æãã¾ãã