星空网 > 软件开发 > 操作系统

关于使用底部菜单栏的使用。。。

要使用它的话, 首先,  你要引用你的库 到你的当前工程里面, 操作方式如下,右键你当前的工程, build path 下的 Congfig Build Path,进入android,点击add  然后,就有你的库的工程,双击就ok。关于使用底部菜单栏的使用。。。images/loading.gif' data-original="http://images2015.cnblogs.com/blog/935179/201604/935179-20160413143814238-430546536.png" />如图

 

 

上面的步骤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;
}
}
});
}
}

然后你的布局文件的话 就要写上你的控件的包名 + 类名咯。 详细

<RelativeLayout 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>

说了这么多,看看效果吧。

 

关于使用底部菜单栏的使用。。。

 

好了 就看一张效果就好了 ,我个人认为这个很好使用的哦, 底部页面的切换也都实现了 。 

 还有我是新手,如有说的不对的地方 请大神指教。 

 

 

关于使用底部菜单栏的使用。。。



原标题:关于使用底部菜单栏的使用。。。

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

在境外开账户:https://www.goluckyvip.com/tag/79856.html
商品成长分:https://www.goluckyvip.com/tag/7986.html
卫浴产品出海:https://www.goluckyvip.com/tag/7987.html
卫浴电商市场:https://www.goluckyvip.com/tag/7988.html
直播地址:https://www.goluckyvip.com/tag/7989.html
工厂爆单:https://www.goluckyvip.com/tag/799.html
深圳有没有比较好玩的景点 深圳有没有比较好玩的景点推荐一下:https://www.vstour.cn/a/366175.html
长治婚庆女司仪和主持人:https://www.vstour.cn/a/366176.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流