
android 菜单 怎么让同一个选项菜单在任何一个页面都能显示.
2017-06-18
展开全部
给例吧自研究
import java_error));
} else {
callBack_error));
}
}
}
/**
* 服务器获取数据任务线程
* */
class BaseTask implements Runnable {
private Context context;
private RequestVo reqVo;
private Handler handler;
public BaseTask(Context context, RequestVo reqVo, Handler handler) {
this.context = context;
this.reqVo = reqVo;
this.handler = handler;
}
@Override
public void run() {
Object obj = null;
Message msg = new Message();
if (NetUtil.hasNetwork(context)) {
obj = NetUtil.post(reqVo);
msg.what = Constant.SUCCESS;
msg.obj = obj;
handler.sendMessage(msg);
} else {
msg.what = Constant.NET_FAILED;
msg.obj = obj;
handler.sendMessage(msg);
}
}
}
/**
* 加载底部Tab
*/
protected void loadBottomTab() {
// 初始化控件
ImageView localImageView1 = (ImageView) findViewById(R.id.imgHome);// 首页
this.home = localImageView1;
ImageView localImageView2 = (ImageView) findViewById(R.id.imgSearch);// 搜索
this.search = localImageView2;
ImageView localImageView3 = (ImageView) findViewById(R.id.imgShoppingCar);// 购物车
this.shopCar = localImageView3;
ImageView localImageView4 = (ImageView) findViewById(R.id.imgEbuy);// 我帐户
this.myEbuy = localImageView4;
ImageView localImageView5 = (ImageView) findViewById(R.id.imgMore);// 更
this.more = localImageView5;
this.textShopCarNum = (TextView) findViewById(R.id.textShopCarNum);
// DBopt = new ShopcarDataOperation(this);
// //拿购物车内商品数量0显示购物车商品数量TextView
// goods_lists = DBopt.getDataListToShow(ShopcarDatabase.GOODS_TABLE,
// username);//???????????????????????????
// if(goods_lists.size() > 0){
// textShopCarNum.setVisibility(TextView.VISIBLE);
// textShopCarNum.setText(goods_lists.size()+"");
// System.out.println("购物车数量: "+goods_lists.size());
// }else{
// textShopCarNum.setVisibility(TextView.GONE);
// }
// 控件添加点击事件监听
this.home.setOnClickListener(this);
this.search.setOnClickListener(this);
this.shopCar.setOnClickListener(this);
this.myEbuy.setOnClickListener(this);
this.more.setOnClickListener(this);
}
/**
* 根据传递点击id切换tab图片
*
* @param paramViewId
*/
protected void selectedBottomTab(int paramViewId) {
this.home.setBackgroundResource(R.drawable.tab_home_normal);
this.search.setBackgroundResource(R.drawable.tab_search_normal);
this.shopCar.setBackgroundResource(R.drawable.tab_shopping_normal);
this.myEbuy.setBackgroundResource(R.drawable.tab_myebuy_normal);
this.more.setBackgroundResource(R.drawable.tab_more_normal);
switch (paramViewId) {
case Constant.HOME:
this.home.setBackgroundResource(R.drawable.tab_home_pressed);
Constant.defaultIndex = Constant.HOME;
break;
case Constant.SEARCH:
this.search.setBackgroundResource(R.drawable.tab_search_pressed);
Constant.defaultIndex = Constant.SEARCH;
break;
case Constant.SHOPCAR:
this.shopCar.setBackgroundResource(R.drawable.tab_shopping_pressed);
Constant.defaultIndex = Constant.SHOPCAR;
break;
case Constant.MYEBUY:
this.myEbuy.setBackgroundResource(R.drawable.tab_myebuy_pressed);
Constant.defaultIndex = Constant.MYEBUY;
break;
case Constant.MORE:
this.more.setBackgroundResource(R.drawable.tab_more_pressed);
Constant.defaultIndex = Constant.MORE;
break;
}
}
public static boolean isIslogin() {
return islogin;
}
public static void setIslogin(boolean islogin) {
BaseActivity.islogin = islogin;
}
/**
* 否加载底部tab默认加载
*
* @return
*/
protected Boolean isLoadBottomTab() {
return true;
}
/**
*
* 数据调接口
*
*/
public abstract interface DataCallback<T> {
public abstract void processData(T paramObject, boolean paramBoolean);
}
/**
* 服务器获取数据并调处理
*
* @param reqVo
* @param callBack
*/
protected void getDataFromServer(RequestVo reqVo, DataCallback callBack) {
showProgressDialog();
BaseHandler handler = new BaseHandler(this, callBack, reqVo);
BaseTask taskThread = new BaseTask(this, reqVo, handler);
this.threadPoolManager.addTask(taskThread);
}
/**
* 显示进度框
*/
protected void showProgressDialog() {
if ((!isFinishing()) && (this.progressDialog == null)) {
this.progressDialog = new ProgressDialog(this);
}
this.progressDialog.setTitle(getString(R.string.loadTitle));
this.progressDialog.setMessage(getString(R.string.LoadContent));
this.progressDialog.show();
}
/**
* 关闭进度框
*/
protected void closeProgressDialog() {
if (this.progressDialog != null)
this.progressDialog.dismiss();
}
/**
* 寻找控件
*/
protected abstract void findViewById();
/**
* Activity加载布局文件
*/
protected abstract void loadViewLayout();
/**
* 向台请求数据
*/
protected abstract void processLogic();
/**
* 控件设置监听
*/
protected abstract void setListener();
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询