底部導(dǎo)航欄設(shè)計(jì)_第1頁
底部導(dǎo)航欄設(shè)計(jì)_第2頁
底部導(dǎo)航欄設(shè)計(jì)_第3頁
底部導(dǎo)航欄設(shè)計(jì)_第4頁
底部導(dǎo)航欄設(shè)計(jì)_第5頁
已閱讀5頁,還剩6頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、Android應(yīng)用底部導(dǎo)航欄(選項(xiàng)卡)實(shí)例現(xiàn)在很多android的應(yīng)用都采用底部導(dǎo)航欄的功能,這樣可以使得用戶在使用過程中隨意切換不同的頁面,現(xiàn)在我采用TabHost組件來自定義一個(gè)底部的導(dǎo)航欄的功能。我們先看下該demo實(shí)例的框架圖:其中各個(gè)類的作用以及資源文件就不詳細(xì)解釋了,還有資源圖片(在該Demo中借用了其它應(yīng)用程序的資源圖片)也不提供了,大家可以自行更換自己需要的資源圖片。直接上各個(gè)布局文件或各個(gè)類的代碼:1 res/layout目錄下的maintabs.xml源碼:html 2 res/drawablehtml 3 res/values 下的源碼:dimens.xml源碼html

2、10.0sp 5.0dip 2.0dip 30.0sp 100.0dip 48.0dip 20.0dip 19.0dip 10.0dip 20.0dip 10.0dip 35.0dip 74.0dip 70.0dip 13.299988dip 20.0dip 0.0dip 20.0sp 10.0dip 50.0dipdrawables.xml源碼:html #fff4f4f4 #fffff4db #ff000000 #00000000 android:color/transparent #99000000 #fff4f4f4 #ff272727 #ff333333ids.xml源碼:html

3、false false false false false falsestrings.xml源碼:html Hello World, MainTabActivity! TabDemo 消息 首頁 更多 時(shí)間 好友styles.xml源碼:html dimen/bottom_tab_font_size #ffffffff marquee center_horizontal drawable/home_btn_bg dimen/bottom_tab_padding_up 2.0dip fill_parent wrap_content 2.0dip null true dimen/bottom_ta

4、b_padding_drawable 1.0 4 src/包下面各個(gè)UI界面類源碼:MainTabActivity.java源碼:htmlpackage ;import ;import ;import ;import ;import ;import ;import ;import ;public class MainTabActivity extends TabActivity implements OnCheckedChangeListener private TabHost mTabHost; private Intent mAIntent; private Intent mBIntent

5、; private Intent mCIntent; private Intent mDIntent; private Intent mEIntent; /* Called when the activity is first created. */ Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(); this.mAIntent =

6、new Intent(this,AActivity.class); this.mBIntent = new Intent(this,BActivity.class); this.mCIntent = new Intent(this,CActivity.class); this.mDIntent = new Intent(this,DActivity.class); this.mEIntent = new Intent(this,EActivity.class); (RadioButton) findViewById(R.id.radio_button0) .setOnCheckedChange

7、Listener(this); (RadioButton) findViewById(R.id.radio_button1) .setOnCheckedChangeListener(this); (RadioButton) findViewById(R.id.radio_button2) .setOnCheckedChangeListener(this); (RadioButton) findViewById(R.id.radio_button3) .setOnCheckedChangeListener(this); (RadioButton) findViewById(R.id.radio_

8、button4) .setOnCheckedChangeListener(this); setupIntent(); Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) if(isChecked) switch (buttonView.getId() case R.id.radio_button0: (A_TAB); break; case R.id.radio_button1: (B_TAB); break; case R.id.radio_button2: (C_TAB);

9、break; case R.id.radio_button3: (D_TAB); break; case R.id.radio_button4: (MORE_TAB); break; private void setupIntent() this.mTabHost = getTabHost(); TabHost localTabHost = this.mTabHost; localTabHost.addTab(buildTabSpec(A_TAB, , R.drawable.icon_1_n, this.mAIntent); localTabHost.addTab(buildTabSpec(B

10、_TAB, , R.drawable.icon_2_n, this.mBIntent); localTabHost.addTab(buildTabSpec(C_TAB, , R.drawable.icon_3_n, this.mCIntent); localTabHost.addTab(buildTabSpec(D_TAB, , R.drawable.icon_4_n, this.mDIntent); localTabHost.addTab(buildTabSpec(MORE_TAB, , R.drawable.icon_5_n, this.mEIntent); private TabHost

11、.TabSpec buildTabSpec(String tag, int resLabel, int resIcon, final Intent content) return (tag).setIndicator(getString(resLabel), getResources().getDrawable(resIcon).setContent(content); 其中AActivity.java 與BActivity.java ,CActivity.java ,DActivity.java ,EActivity.java 中的源碼都一樣,只是用來表示不同的界面展示,故這里只列出AActivity.java的源碼:htmlpackage ;import ;import ;import ;import ;public class AActivity extends Activity Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText(This is

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論