美团APP商家页面Android代码,美团_cc商家页面实现

public class ShopFragment extends Fragment implements OnClickListener {

private List mGoodList = new ArrayList();

private View mLayout;

private TextView mTvTab1;

private TextView mTvTab2;

private TextView mTvTab3;

private TextView mTvTab4;

private int[] textViewIDs = new int[] { R.id.tv_tab1, R.id.tv_tab2,

R.id.tv_tab3, R.id.tv_tab4 };

private MyAdapter mAdapter;

private DisplayImageOptions options;

private ImageView mLoadingAnim;

private AnimationDrawable mDrawable;

private View mLayLoading;

private int mPos = 0;

private ListView mListView;

@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container,

Bundle savedInstanceState) {

if (mLayout == null) {

mLayout = inflater.inflate(R.layout.fragment_shop, container,

false);

initUI();

// 注册广播,更新TextView

IntentFilter filter = new IntentFilter();

filter.addAction(MeituanConstants.BroadcastKey.ACTION_CHANGETEXTVIEW);

getActivity().registerReceiver(new MyRecivice(), filter);

getJson();

initUIL();// 解析图片

setLoadingAnim();

}

return mLayout;

}

private void setLoadingAnim() {

//设置下载动画

mLayLoading.setVisibility(View.VISIBLE);

mDrawable.stop();

mDrawable.start();

}

private void initUIL() {

options = new DisplayImageOptions.Builder()

.showImageOnLoading(R.drawable.ic_review_score_tip_good_off)

// 设置图片在下载期间显示的默认图片

.showImageForEmptyUri(R.drawable.ic_review_score_tip_good_off)

// 设置URI错误或者为空时显示的图片

.showImageOnFail(R.drawable.ic_review_score_tip_good_off)

// 设置图片加载或者解析出现错误时设置的图片

.cacheInMemory(true)

// 是否内存缓存

.cacheOnDisk(true)

// 是否外存缓存

.considerExifParams(true)

// .displayer(new RoundedBitmapDisplayer(100))// 是否设置图片圆角

.displayer(new FadeInBitmapDisplayer(200))// 图片加载好之后渐入的时间

.build();

}

private void getJson() {

MyVolley.get(getActivity(), MeituanConstants.UrlPath.XINDANJINGXUAN,

new VolleyListener() {

@Override

public void onErrorResponse(VolleyError arg0) {

arg0.getMessage();

}

@Override

public void onResponse(String arg0) {

parseJson(arg0);

}

});

}

protected void parseJson(String arg0) {

CainixihuanInfo info = GsonUtils.parseJSON(arg0, CainixihuanInfo.class);

mGoodList.addAll(info.getGoodlist());

if(mGoodList.size() > 10){

mLayLoading.setVisibility(View.GONE);

mDrawable.stop();

}

//new Handler().postDelayed(new Runnable() {

//@Override

//public void run() {

//mLayLoading.setVisibility(View.GONE);

//mDrawable.stop();

//}

//}, 3000);

mAdapter.notifyDataSetChanged();

}

private void initUI() {

initListView();

mLayLoading = mLayout.findViewById(R.id.layout_loading);

mLoadingAnim = (ImageView) mLayout.findViewById(R.id.img_loading);

mDrawable = (AnimationDrawable) mLoadingAnim.getDrawable();

mLayout.findViewById(R.id.rl_map_btn).setOnClickListener(this);

mLayout.findViewById(R.id.rl_tab1).setOnClickListener(this);

mLayout.findViewById(R.id.rl_tab2).setOnClickListener(this);

mLayout.findViewById(R.id.rl_tab3).setOnClickListener(this);

mLayout.findViewById(R.id.rl_tab4).setOnClickListener(this);

mLayout.findViewById(R.id.rl_search_btn).setOnClickListener(this);

mTvTab1 = (TextView) mLayout.findViewById(R.id.tv_tab1);

mTvTab2 = (TextView) mLayout.findViewById(R.id.tv_tab2);

mTvTab3 = (TextView) mLayout.findViewById(R.id.tv_tab3);

mTvTab4 = (TextView) mLayout.findViewById(R.id.tv_tab4);

}

private void initListView() {

mListView = (ListView) mLayout.findViewById(R.id.listView1);

mAdapter = new MyAdapter();

mListView.setAdapter(mAdapter);

mListView.setOnItemClickListener(new OnItemClickListener() {

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值