给例吧自研究
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