Time of Update: 2018-12-05
剛剛學安卓,看到書中的事件一直是固定死的,我對 java 上的這個還不太清楚,應該是什麼匿名類吧,覺得不爽,事件應該是可以在運行時指定的,這樣才靈活於是就從網上搜(我的基礎差,沒有辦法)。實驗成功的代碼: package android.zziss.hello;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.widget.Button;import
Time of Update: 2018-12-05
Time of Update: 2018-12-05
費了九牛二虎之力,終於把Cocos2d在Andriod上跑通了。在安裝期間碰到了各種各樣的坑,這裡我把這些坑總結一下。 通過Cocos2dx官方資料知道要在Andriod下搭建環境需要四樣前置條件:cygwinndkcocos2dxandroid-sdk-tools 上述前置條件各自的用途請自行google。這裡只描述搭建環境中所遇到的坑。 1.cygwin 安裝cygwin 坑1-1.通過一番搜尋,包括小白的Blog,裝起來那叫一個慢啊~經常到一半中斷,總之下了2天沒下完,換鏡像
Time of Update: 2018-12-05
剛學 listview ,參考網上的教程http://www.cnblogs.com/allin/archive/2010/05/11/1732200.html自己實現了一個 listview ,使用的是 SimpleAdapter
Time of Update: 2018-12-05
自動完成就是在輸入框中輸入字母,然後自己找到相近的詞,這個在 android 中需要先把詞給指定出來,書中用到的是 靜態數組,這裡改成了資源檔有兩個自動完成的輸入框:AutoCompleteTextView 與 MultiAutoCompleteTextView 區別是: AutoCompleteTextView 只能自動完成一個,而 MultiAutoCompleteTextView 可以自動完成多個,中間是用 逗號分開的代碼很簡單java代碼:package zziss.android.
Time of Update: 2018-12-05
Radio 單選是由 RadioGroup 與 RadioButton
Time of Update: 2018-12-05
CheckBox練習: checkbox 和 radioButton 相比,不需要 RadioGroup ,每個 checkbox 是單獨的控制項,使用很簡單 isChecked 是擷取是否選擇中,選擇時有 CheckedChangeListener 監聽,具體請看代碼 java 代碼,該代碼簡化了在每個chekcbox 中寫 setOnCheckedChangeListener
Time of Update: 2018-12-05
ImageButton 是就圖片按紐,指定一個圖片資源,就可以,其它的使用和 Button 是一樣的,這裡再熟悉一下對話方塊的使用,代碼如下xml
Time of Update: 2018-12-05
android 中的 AlertDialog 對話方塊由 AlertDialog.builder 進行建立,建立後使用 show 顯示,使用簡單,代碼如下 對話方塊的 xml 定義 <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
Time of Update: 2018-12-05
下拉式清單 spinner,這個使用很簡單,在 xml 中定義一個標籤,然後指定 ArrayAdapter<String> 就可以了,Adapter 需要指定下拉的布局。關於下拉的資料,書中是寫用靜態數組,我這裡改成了從資源檔中讀取java
Time of Update: 2018-12-05
在調試時出現了:java.io.IOException: Unable to upload file: No space left on device原因是我的 apk 太大了,解決方案找到 avd 目錄 下的模擬器目錄C:\Documents and Settings\qijianzhou\.android\avd\advv4.avd修改 config.ini 檔案添加一句 disk.dataPartition.size=1024 hw.lcd.density=120sdcard.size=5
Time of Update: 2018-12-05
Gallery 是顯示圖片用的,需要指定一個圖片的來源 adapter ,這個繼承自 BaseAdapter ,具體代碼如下xml
Time of Update: 2018-12-05
//建立Toast對象 02 Toast mToast = Toast.makeText(ShareYourLifeActivity.this, "記憶卡不可用,請檢查...", Toast.LENGTH_LONG); 03 04 //建立LinearLayout布局 05 LinearLayout toastView = (LinearLayout) mToast.getView(); 06
Time of Update: 2018-12-05
在 android 中顯示圖片使用的是 ImageView ,這裡的代碼是從書中的例子來的,使用很簡單,現在才覺得 android開發真的好方便呀代碼如下:xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:
Time of Update: 2018-12-05
ImageSwitch 需要一個 ViewFactory 介面方法,返回一個 ImageView 對像,同時指定 setFactory 方法其中試了試用 ImageView 實現 ImageSwitcher
Time of Update: 2018-12-05
1、Android團隊提供的樣本項目 如果不是從學習Android SDK中提供的那些範例代碼開始,可能沒有更好的方法來掌握在Android這個架構上開發。由Android的核心Team Dev提供了15個優秀的樣本項目,包含了遊戲、影像處理、時間顯示、開始菜單捷徑等。 地址:http://www.apkbus.com/android-13506-1-1.html 2、 Remote Droid RemoteDroid是一個Android應用,能夠讓使用者使用自己的無線網路使用無線鍵盤、
Time of Update: 2018-12-05
常用的一些屬性說明 android:id --- 為控制項指定相應的ID android:text --- 指定控制項當中顯示的文字,需要注意的是,這裡盡量使用strings.xml檔案當中的字串 android:grivity --- 指定控制項的基本位置,比如說置中,居右等位置 這裡指的是控制項中的文本位置並不是控制項本身。 android:textSize --- 指定控制項當中字型的大小 android:background ---
Time of Update: 2018-12-05
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Galle
Time of Update: 2018-12-05
SharedPreferences 儲存,這個常用於程式內的一些配置項的儲存,使用比 symbian 要簡單好多,代碼很簡單,測試時使用的是 String
Time of Update: 2018-12-05
Android 1.5測試通過 只需在以下代碼中的,setCurrentView();之前調用即可http://hi.baidu.com/wishwingliao/blog/item/38feb71c994ae98587d6b6e0.html /** * 標題列隱藏,在Activity.setCurrentView();之前調用此方法 */ private void HideTitle() { requestWindowFeature(