標籤:
getIntent().getExtras().get("intent"); 這個intent是資料封裝的參數。 比如: Intent intent = new Intent(this, YouClass.class); intent.putExtra("data1","youdata"); startActivit(intent ); 擷取資料 getIntent().getExtras().get("data1");
不用執行個體化 就像引用的就只有類裡面設為靜態方法的資料和方法才行
listview中onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) ? 後面有4個參數,乍看直接暈菜,那麼每個參數究竟是何意義呢. 舉個例子會理解的更快:X, Y兩個listview,X裡有1,2,3,4這4個item,Y裡有a,b,c,d這4個item。 如果你點了b這個item。如下: / /arg0相當於listview Y適配器的一個指標,可以通過它來獲得Y裡裝著的一切東西,再通俗點就是說告訴你,你點的是Y,不是X // arg1是你點的b這個view的控制代碼,就是你可以用這個view,來獲得b裡的控制項的id後操作控制項 // arg2是b在Y適配器裡的位置(產生listview時,適配器一個一個的做item,然後把他們按順序排好隊,在放到listview裡,意思就是這個b是第position號做好的) // arg3是b在listview Y裡的第幾行的位置(很明顯是第2行),大部分時候position和id的值是一樣的,如果需要的話,你可以自己加個log把position和id都弄出來在logcat裡瞅瞅
The type MyIntentService must implement the inherited abstract method IntentService.onHandleIntent(Intent) 抽象方法被繼承必須要在裡面實現 有沒有實現的方法(抽象類別、介面裡的方法必須都實現)
span是行內元素;div是區塊層級元素;他們都是容器!
在實際開發中LayoutInflater這個類還是非常有用的,它的作用類似於findViewById()。不同點是LayoutInflater是用來找res/layout/下的xml布局檔案,並且執行個體化;而findViewById()是找xml布局檔案下的具體widget控制項(如Button、TextView等)。 具體作用: 1、對於一個沒有被載入或者想要動態載入的介面,都需要使用LayoutInflater.inflate()來載入;
對於一個已經載入的介面,就可以使用Activiyt.findViewById()方法來獲得其中的介面元素
關於android控制項的屬性常見問題 align:對齊 parent:容器 bottom:底部 alignparentbottom:是否顯示在容器底部。 值為true 或者 false android:layout_alignParentBottom="true" 這個控制項的下邊距為30dip 就是這個控制項和他下方的控制項距離為30dip android:layout_marginBottom="30dip" 廣播接收器中不允許開啟線程,所以不要在onreceive()中加入耗時的操作
菜單的使用: 當你的應用程式目標設為蜂巢平台時,你可以利用Action Bar組件提供的全部功能,將你的選項功能表項目放在Action Bar的右上方,對使用者來說使用更方便,控制該行為的主功能表項目屬性是android:showAsAction。 這個屬性可接受的值有: 1、always:這個值會使功能表項目一直顯示在Action Bar上。 2、ifRoom:如果有足夠的空間,這個值會使功能表項目顯示在Action Bar上。 3、never:這個值使功能表項目永遠都不出現在Action Bar上。 4、withText:這個值使功能表項目和它的表徵圖,菜單文本一起顯示。
android:layout_centerHorizontal="true" --將控制項置於水平方向的中心位置
相對布局: 其他屬性有: android:layout_above="@id/xxx" --將控制項置於給定ID控制項之上 android:layout_below="@id/xxx" --將控制項置於給定ID控制項之下 android:layout_toLeftOf="@id/xxx" --將控制項的右邊緣和給定ID控制項的左邊緣對齊 android:layout_toRightOf="@id/xxx" --將控制項的左邊緣和給定ID控制項的右邊緣對齊 android:layout_alignLeft="@id/xxx" --將控制項的左邊緣和給定ID控制項的左邊緣對齊 android:layout_alignTop="@id/xxx" --將控制項的上邊緣和給定ID控制項的上邊緣對齊 android:layout_alignRight="@id/xxx" --將控制項的右邊緣和給定ID控制項的右邊緣對齊 android:layout_alignBottom="@id/xxx" --將控制項的底邊緣和給定ID控制項的底邊緣對齊 android:layout_alignParentLeft="true" --將控制項的左邊緣和父控制項的左邊緣對齊 android:layout_alignParentTop="true" --將控制項的上邊緣和父控制項的上邊緣對齊 android:layout_alignParentRight="true" --將控制項的右邊緣和父控制項的右邊緣對齊 android:layout_alignParentBottom="true" --將控制項的底邊緣和父控制項的底邊緣對齊 android:layout_centerInParent="true" --將控制項置於父控制項的中心位置 android:layout_centerVertical="true" --將控制項置於垂直方向的中心位 android:layout_maginBottom="10dip"用於指定離下面的距離
listview設定分割線屬性: <ListView android:id="@+id/listView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:divider="#FFF" android:dividerHeight="1px" android:layout_margin="10dip"/> 即android:gravity用於設定View中內容相對於View組件的對齊,而android:layout_gravity用於設定View組件相對於Container的對齊。
顏色的: Black 黑色 #000000 Maroon 深褐色 #800000 Green 綠色 #008000 Olive 橄欖色 #808000 Navy 海軍藍 #000080 Purple 紫色 #800080 Teal 水鴨綠 #008080 Gray 灰色 #808080 Silver 銀色 #C0C0C0 Red 紅色 #FF0000 Lime 酸橙色 #00FF00 Yellow 黃色 #FFFF00 Blue 藍色 #0000FF Fuchsia 品紅 #FF00FF Aqua 水藍 #00FFFF White 白色 #FFFFFF
關於標題列:actionbar 可以實現titlebar和menu的功能,要自訂titlebar的話就得先定義一個主題然後在程式中匯入建立的title布局 設定為全屏的兩種方式:
一種是android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
還有一種是android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
android 學習筆記 雜記1