freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

android開發(fā)技巧總匯android開發(fā)培訓-教師必備(參考版)

2025-04-19 12:27本頁面
  

【正文】 一下通過簡單例子說明: 創(chuàng)建Test 繼承ListActivit。運行效果如下圖: LIST例二ListView 是android開發(fā)中最常用的組件之一,它通過一個adapter來構建顯示通常有三種adapter可以使用ArrayAdapter ,SimpleAdapter,CursorAdapter。那 再繪制下一行,直到繪完為止。在這個函數里面首先獲得一個View(實際上是一個ViewGroup),然后再實例并設置各個組件,顯示之。至此一個自定義的listView就完成了,現在讓我們回過頭從新審視這個過程。這樣便可以將數據對應到各個組件上了。getView()有三個參數,position表示將顯示的是第幾行,covertView是從布局文件中inflate來的布局。當手動完成適配時,必須手動映射數據,這需要重寫getView()方法。如果你的getCount()返回值是0的話,列表將不顯示同樣return 1,就只顯示一行。 return convertView。 (new () { Override public void onClick(View v) { showInfo()。 ((String)(position).get(title))。 }else { holder = (ViewHolder)()。 = (Button)()。 = (TextView)()。 convertView = (, null)。 } Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null。 } Override public Object getItem(int arg0) { // TODO Autogenerated method stub return null。 public MyAdapter(Context context){ = (context)。 public Button viewBtn。 public TextView title。}/** * listview中點擊按鍵彈出對話框 */public void showInfo(){ new (this) .setTitle(我的listview) .setMessage(介紹...) .setPositiveButton(確定, new () { Override public void onClick(DialogInterface dialog, int which) { } }) .show()。 return list。 (img, )。 (title, G3)。 (map)。 (info, google 2)。 map = new HashMapString, Object()。 (img, )。 (title, G1)。}private ListMapString, Object getData() { ListMapString, Object list = new ArrayListMapString, Object()。 MyAdapter adapter = new MyAdapter(this)。Overridepublic void onCreate(Bundle savedInstanceState) { (savedInstanceState)。并告訴你ListView究竟是如何工作的。但是事實并非這樣,因為按鈕是無法映射的,即使你成功的用布局文件顯示出了按鈕也無法添加按鈕的響應,這時就要研究一下ListView是如何現實的了,而且必須要重寫一個類繼承BaseAdapter。運行效果如下圖: 有按鈕的ListView 但是有時候,列表不光會用來做顯示用,我們同樣可以在在上面添加按鈕。布局文件的組件id,title,info,img。因為系統(tǒng)沒有對應的布局文件可用。}}復制代碼使用simpleAdapter的數據用一般都是HashMap構成的List,list的每一節(jié)對應ListView的每一行。 (map)。 (info, google 3)。 map = new HashMapString, Object()。 (img, )。 (title, G2)。 (map)。 (info, google 1)。 MapString, Object map = new HashMapString, Object()。 setListAdapter(adapter)。Overridepublic void onCreate(Bundle savedInstanceState) { (savedInstanceState)。下面的程序是實現一個帶有圖片的類表。注意::usespermission android:name=/usespermission運行后效果如下圖: SimpleAdaptersimpleAdapter的擴展性最好,可以定義各種各樣的布局出來,可以放上ImageView(圖片),還可以放上Button(按鈕),CheckBox(復選框)等等。其作用是自動的將String型數組所表示的每一列數據映射到布局文件對應id的組件上。我們將獲得的Cursor對象交由Activity管理,這樣Cursor的生命周期和Activity便能夠自動同步,省去自己手動管理Cursor。先獲得一個指向系統(tǒng)通訊錄數據庫的Cursor對象獲得數據來源。 setContentView(listView)。 ListAdapter listAdapter = new SimpleCursorAdapter(this, , cursor, new String[]{}, new int[]{})。 Cursor cursor = getContentResolver().query(, null, null, null, null)。Overridepublic void onCreate(Bundle savedInstanceState){ (savedInstanceState)。 /*** author allin**/public class MyListView2 extends Activity {private ListView listView。先在通訊錄中添加一個聯(lián)系人作為數據庫的數據。簡單的說就是方便把從游標得到的數據進行列表顯示,并可以把指定的列映射到對應的TextView中。同時用setAdapter()完成適配的最后工作。 return data。 (測試數據3)。 (測試數據1)。 setContentView(listView)。 listView = new ListView(this)。//private ListString data = new ArrayListString()。SimpleCursorAdapter可以認為是SimpleAdapter對數據庫的簡單結合,可以方面的把數據庫的內容以列表的形式展示出來。 根據列表的適配器類型,列表分為三種,ArrayAdapter,SimpleAdapter和SimpleCursorAdapter其中以ArrayAdapter最為簡單,只能展示一行字。2.適配器 用來把數據映射到ListView上的中介。抽空把對ListView的使用做了整理,并寫了個小例子,如下圖。  }  return (menu)。  break?! reak?! reak。  //動態(tài)加入數組中對應的XML MENU菜單  break。//清空MENU菜單  // Inflate the currently selected menu XML resource.  MenuInflater inflater = getMenuInflater()?!   }  然后onCreateOptionsMenu(Menu menu) 方法中通過MenuInflater過濾器動態(tài)加入MENU  Override  public boolean onCreateOptionsMenu(Menu menu) {  // TODO Autogenerated method stub  // Hold on to this  myMenu = menu?!   if ((“Four”)) {  myMenuSettingTag = 4?!   if ((“Two”)) {  myMenuSettingTag = 2?! 、岣鱾€標簽頁的動態(tài)MENU  先把在XML中設計好的MENU放到一個int數組里  private static final int myMenuResources[] = { ,  , , }?! ?/設置一下TabHost的顏色 ?、呓又?,在TabHost創(chuàng)建一個標簽,然后設置一下標題/圖標/標簽頁布局  myTabhost  .addTab((“TT”)// 制造一個新的標簽TT  .setIndicator(“KK”,  getResources().getDrawable())  // 設置一下顯示的標題為KK,設置一下標簽圖標為ajjc  .setContent())。//從TabActivity上面獲取放置Tab的TabHost  (this).inflate(, (), true)?!   } ?、?Activity) ?、葸@時候,需要設計一下標簽頁對應的布局,一般采用FrameLayout作為根布局,每個標簽頁面對應一個子節(jié)點的Layout   android:layout_width=”fill_parent” android:layout_height=”fill_parent”   android:layout_width=”fill_parent” android:layout_height=”fill_parent”  androidrientation=”vertical” android:layout_height=”wrap_content” android:text=”EditText”  android:textSize=”18sp”   android:layout_height=”wrap_content” android:text=”Button”   android:layout_width=”fill_parent” android:layout_height=”fill_parent”  androidrientation=”vertical”   android:layout_width=”wrap_content” android:layout_height=”wrap_content”   android:layout_width=”fill_parent” android:layout_height=”fill_parent”  androidrientation=”vertical”  android:layout_width=”166px” android:layout_height=”98px”  androidrientation=”vertical”  android:layout_width=”wrap_content” android:layout_height=”wrap_content”  android:text=”RadioButton”   android:layout_width=”wrap_content” android:layout_height=”wrap_content”  android:text=”RadioButton”  ⑥首先,應該聲明TabHost,然后用LayoutInflater過濾出布局來,給TabHost加上含有Tab頁面的FrameLayoutprivate TabHost myTabhost?! mport ?! ublic class MyTab extends TabActivity {  } ?、蹚母割惱^承OnCreate()入口方法  package ?! 、傩陆ㄒ粋€Tab項目,注意,不要生成main Activity  這里不
點擊復制文檔內容
教學教案相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1