關於使用底部菜單欄的使用。。。

来源:http://www.cnblogs.com/lumin0412/archive/2016/04/13/5387110.html
-Advertisement-
Play Games

要使用它的話, 首先, 你要引用你的庫 到你的當前工程裡面, 操作方式如下,右鍵你當前的工程, build path 下的 Congfig Build Path,進入android,點擊add 然後,就有你的庫的工程,雙擊就ok。如圖 上面的步驟ok的話,現在就開始使用你的框架了 。 具體 應用的代 ...


要使用它的話, 首先,  你要引用你的庫 到你的當前工程裡面, 操作方式如下,右鍵你當前的工程, build path 下的 Congfig Build Path,進入android,點擊add  然後,就有你的庫的工程,雙擊就ok。如圖

 

 

上面的步驟ok的話,現在就開始使用你的框架了 。  具體

應用的代碼就附在下麵吧。

 

package com.example.bluetooth;

import java.util.ArrayList;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.Window;
import android.widget.LinearLayout;

import com.weight.tabbottomlib.view.Item;
import com.weight.tabbottomlib.view.MyBottomLayout;
import com.weight.tabbottomlib.view.MyBottomLayout.ICallbackLister;

public class MainActivity extends Activity {
MyBottomLayout bot;
ArrayList<Item> itemData = new ArrayList<Item>();
LinearLayout myContent;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
init();
}

/**
* 初始化方法
*/
private void init() {
findId();
initData();
setPageContent(new HomeFragment());
initclick();
}

/**
*
* @Title: setPageContent
* @Description: 設置那個頁面的內容
* @param @param fragment:提交內容的Fragment
* @return
* @throws
*/
public void setPageContent(Fragment fragment) {
FragmentManager manager = getFragmentManager();
FragmentTransaction ft = manager.beginTransaction();
ft.replace(R.id.context, fragment);
ft.commit();
}

/**
* 初始化底部菜單欄的數據
*/
private void initData() {
for (int i = 0; i < 3; i++) {
switch (i) {
case 0:
// item.setDrawableNormalId();
Item item = new Item(R.drawable.bottom_fp_nor,
R.drawable.bottom_fp_pre, "首頁");
itemData.add(item);
break;
case 1:
Item item1 = new Item(R.drawable.bottom_ph_nor,
R.drawable.bottom_ph_pre, "陪護師");
itemData.add(item1);
break;
case 2:
Item item2 = new Item(R.drawable.bottom_bbs_nor,
R.drawable.bottom_bbs_pre, "陪護時光");
itemData.add(item2);
break;
}
}
bot.addBottomLayoutValue(itemData);

}

/**
* 找id
*/
private void findId() {
bot = (MyBottomLayout) findViewById(R.id.bottom);
myContent = (LinearLayout) findViewById(R.id.context);
}

/**
* 初始化點擊事件 回調
*/
private void initclick() {
bot.setOnCallbackLister(new ICallbackLister() {

@Override
public void click(int id) {
switch (id) {
case 0:
setPageContent(new HomeFragment());
break;
case 1:
setPageContent(new EscortTeacher());
break;
case 2:
setPageContent(new EscortTime());
break;
}
}
});
}
}

然後你的佈局文件的話 就要寫上你的控制項的包名 + 類名咯。 詳細xml文件如下

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.weight.tabbottomlib.view.MyBottomLayout
android:id="@+id/bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#9000" >
</com.weight.tabbottomlib.view.MyBottomLayout>

<LinearLayout
android:id="@+id/context"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/bottom"
android:orientation="horizontal" >
</LinearLayout>

</RelativeLayout>

說了這麼多,看看效果吧。

 

 

好了 就看一張效果就好了 ,我個人認為這個很好使用的哦, 底部頁面的切換也都實現了 。 

 還有我是新手,如有說的不對的地方 請大神指教。 

 

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 場景一:直接選擇一個聯繫人的電話號碼 這裡不需要先獲取所有的聯繫人自己做聯繫人列表,直接使用系統自帶的AddressBookUI/ABPeoplePickerNavigationController.h就好。 首先需要引入如下三個文件 #import <AddressBookUI/ABPeopleP ...
  • title: 寫技術文章必備的幾個小工具 tags: 小書匠,有道雲筆記,gif錄屏工具 今天給大家推薦寫博客必備的幾個工具,也是我自己每次寫文章用到的。 一.小書匠 這個工具是 345大神 告訴我的,非常好用的MakeDown編輯器,比較常見的網站都支持,例如:csdn,簡書。 "官網下載頁面傳送 ...
  • 前言:第一篇文章,EventBus很多項目都在用,本文參照http://blog.csdn.net/harvic880925/article/details/40660137,自己做了一遍。把有用的挑揀出來,記錄一下啊 一、概述 EventBus是一款針對Android優化的發佈/訂閱事件匯流排。主要 ...
  • 把數據請求和風火輪的效果封裝成一個方法,用的時候直接調用這個方法就可以 + (void)startRequest:(NSString*)method baseurl:(NSString*)baseurl param:(NSDictionary*)params success:(DKSuccess)s ...
  • NSURLConnection,在iOS9被宣佈棄用,本文不使用NSURLConnection進行網路編程,有興趣的童鞋可以參考:iOS開發中的同步、非同步,GET、POST請求方法(NSURLConnection篇) NSURLSession,是在2013年的WWDC上,由Apple提出的NSURL ...
  • Swift支持大部分標準C語言的運算符, 且改進許多特性來減少常規編碼錯誤.如賦值符 = 不返回值, 以防止錯把等號 == 寫成賦值號 = 而導致Bug. 數值運算符( + , -, *, /, %等)會檢測並不允許值溢出, 以此來避免保存變數時由於變數大於或小於其類型所能承載的範圍時導致的異常結果 ...
  • 本文涉及到的WWDC2013 Session有 1.Session 206 Getting Started with UIKit Dynamics 2.Session 221 Advanced Techniques with UIKit Dynamics 什麼是UIKit動力學(UIKit Dyna ...
  • Android 環境搭建 (1)所需材料 eclipse 、ADT 、SDK 下載地址: ADT-15.0.0 android-sdk-windows eclipse-jee-helios-win32 jdk-8u65-windows-x64 http://pan.baidu.com/s/1o7Pu ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...