Android城市索引含定位和热门城市(悬浮块+右侧字母索引

  • Post author:
  • Post category:其他


public void onlisten(){

pic_contact_back.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

finish();

}

});

mAdapter.setOnItemContentClickListener(new IndexableAdapter.OnItemContentClickListener() {

@Override

public void onItemClick(View v, int originalPosition, int currentPosition, UserEntity entity) {

if (originalPosition >= 0) {

intent.putExtra(“info”, entity.getNick());

setResult(RESULT_OK, intent);

finish();

} else {

ToastUtil.showShort(CityPickerActivity.this, “选中Header/Footer:” + entity.getNick() + ” 当前位置:” + currentPosition);

}

}

});

}

/**

  • 自定义的Banner Header

*/

class BannerHeaderAdapter extends IndexableHeaderAdapter {

private static final int TYPE = 1;

//这里传的参数上面注释有

public BannerHeaderAdapter(String index, String indexTitle, List datas) {

super(index, indexTitle, datas);

}

@Override

public int getItemViewType() {

return TYPE;

}

@Override

public RecyclerView.ViewHolder onCreateContentViewHolder(ViewGroup parent) {

View view = LayoutInflater.from(CityPickerActivity.this).inflate(R.layout.item_city_header, parent, false);

VH holder = new VH(view);

return holder;

}

@Override

public void onBindContentViewHolder(RecyclerView.ViewHolder holder, Object entity) {

// 数据源为null时, 该方法不用实现

VH vh = (VH) holder;

list=new ArrayList<>();

for(int i = 0; i<city.length; i++){

list.add(city[i]);

}

System.out.println(“————city”+list);

cybChangeCityGridViewAdapter=new CYBChangeCityGridViewAdapter(CityPickerActivity.this, list);

// 绑定adpter

vh.head_home_change_city_gridview.setAdapter(cybChangeCityGridViewAdapter);

//热门城市的item点击事件

vh.head_home_change_city_gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {

@Override

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

intent.putExtra(“info”, list.get(position));

System.out.println(“aaaaaayyyyyyyyy”+list.get(position));

setResult(RESULT_OK, intent);

finish();

}

});

//设置定位城市的点击事件

vh.item_header_city_dw.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

intent.putExtra(“bendi”, MeNow.city);

setResult(RESULT_OK, intent);

f



版权声明:本文为m0_64319064原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。