91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

高仿大眾點評商家列表

發布時間:2020-07-12 11:20:51 來源:網絡 閱讀:731 作者:小香豬 欄目:移動開發

原生android,高仿大眾點評商家列表;

首先歡迎大家關注我 http://weibo.com/u/2841033197

 

廢話不多說了,上代碼,效果圖

 

高仿大眾點評商家列表

高仿大眾點評商家列表

高仿大眾點評商家列表

 

 適配器

 

class MyAdapter extends BaseAdapter {
 protected final int mItemLayoutId;
 List<Businesses> data = new ArrayList<Businesses>();
 private Context context;
 private LayoutInflater inflater;
 private ImageScaleType p_w_picpathScaleType;
 private DisplayImageOptions options;

 public MyAdapter(List<Businesses> data, Context cxt, int itemLayoutId, ImageScaleType p_w_picpathScaleType) {
  this.data = data;
  this.context = cxt;
  this.mItemLayoutId = itemLayoutId;
  this.inflater = LayoutInflater.from(context);
  this.p_w_picpathScaleType = p_w_picpathScaleType;
  init();
 }
 
 /** 初始化圖片緩存 options **/
 private void init() {
  options = new DisplayImageOptions.Builder()
    .showImageOnLoading(R.drawable.thumb)
    // .showImageOnFail(R.drawable.ic_error)
    .cacheInMemory(true)
    .cacheOnDisk(true)
    .considerExifParams(true)
    .p_w_picpathScaleType(p_w_picpathScaleType != null ? p_w_picpathScaleType: ImageScaleType.EXACTLY)
    .delayBeforeLoading(10)
    .displayer(new SimpleBitmapDisplayer())// //正常顯示一張圖片 
    .build();
 }

 @Override
 public int getCount() {
  // TODO Auto-generated method stub
  return data != null ? data.size() : 0;
 }

 @Override
 public Object getItem(int position) {
  // TODO Auto-generated method stub
  return data != null ? data.get(position) : null;
 }

 @Override
 public long getItemId(int position) {
  // TODO Auto-generated method stub
  return position;
 }

 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
  
  ViewHolder holder = getViewHolder(position, convertView, parent);
  TextView business_id_tv = holder.getView(R.id.business_id_tv);
  TextView name_tv = holder.getView(R.id.name_tv);
  TextView avg_price_tv = holder.getView(R.id.avg_price_tv);
  TextView regions_tv = holder.getView(R.id.regions_tv);
  TextView distance_tv = holder.getView(R.id.distance_tv);
  
  String s_photo_url = data.get(position).getS_photo_url();
  String rating_s_img_url = data.get(position).getRating_img_url();
  int business_id = data.get(position).getBusiness_id();
  String name = data.get(position).getName();
  String branch_name = data.get(position).getBranch_name();
  int avg_price = data.get(position).getAvg_price();
  String regions = data.get(position).getRegions();
  String categories = data.get(position).getCategories();
  int distance =  data.get(position).getDistance();
  
  holder.displayImages(R.id.s_photo_url_iv, s_photo_url);
  holder.displayImages(R.id.star_iv, rating_s_img_url);
  
  business_id_tv.setText("" + business_id);
  name = name.substring(0, name.indexOf("("));
  if (!StringUtils.isEmpty(branch_name)) {
   name = name + "(" +branch_name +")";
  }
  name_tv.setText(name);
  if (avg_price > 0) {
   avg_price_tv.setText("¥" + avg_price +"/人");
  }
  // 過濾下數據
  regions = regions.replace("\"", "").replace("[", "").replace("]", "").split(",")[1];
  categories = categories.replace("\"", "").replace("[", "").replace("]", "");
  regions_tv.setText(regions + " " + categories);
  if (distance > 0) {
   float die = distance;
   DecimalFormat decimalFormat=new DecimalFormat(".0");
   if(die >= 1000) {
    // 大于1000  米 轉化為千米展示數據
    die /= 1000;
    String temp_die = decimalFormat.format(die);
    temp_die = temp_die.replace(".0", "");
    distance_tv.setText(temp_die +"km" );
   } else {
    distance_tv.setText(distance +"m" );
   }
  }
  
  setClick(data, holder.getConvertView(), position);
  return holder.getConvertView();
 }
 
 private ViewHolder getViewHolder(int position, View convertView,
   ViewGroup parent) {
  return ViewHolder.get(context, convertView, parent, mItemLayoutId,
    position, options);
 }

 private void setClick(final List<Businesses> datas, final View convertView,
   final int position) {
  convertView.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View arg0) {
    int business_ids = datas.get(position).getBusiness_id();
    String keywords = "";
    try {
     keywords = URLEncoder.encode("" + business_ids, "UTF-8");
     Uri url = Uri.parse("dianping://shopinfo?id=" + keywords);
     Intent intent = new Intent(Intent.ACTION_VIEW, url);
     context.startActivity(intent);
    } catch (Exception e) {
     // 沒有安裝應用,默認打開HTML5站
     Intent intent = new Intent(Intent.ACTION_VIEW, Uri
       .parse("http://m.dianping.com/search.aspx?skey="
         + keywords));
     context.startActivity(intent);

    }

   }
  });
 }

 源碼本人放在我的常用博客上了, 傳送門

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

维西| 景德镇市| 读书| 通州区| 马关县| 渭南市| 增城市| 迭部县| 漾濞| 凤凰县| 苍溪县| 建瓯市| 蓬莱市| 本溪市| 黄大仙区| 弥勒县| 浑源县| 新化县| 樟树市| 宁晋县| 三原县| 宜宾县| 布尔津县| 舞阳县| 庄浪县| 衡水市| 恩施市| 商南县| 伽师县| 同仁县| 马关县| 灵山县| 佛冈县| 恩平市| 永福县| 永康市| 鸡泽县| 城固县| 尤溪县| 新乐市| 中牟县|