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

private ImageView pic_contact_back;

private Intent intent;

@Override

protected void onCreate(@Nullable Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_pick_contact);

initview();

initAdapter();

onlisten();

}

public void initAdapter(){

mAdapter = new ContactAdapter(this);

indexableLayout.setAdapter(mAdapter);

//设置字母提示框为仿os居中

indexableLayout.setOverlayStyle_Center();

mAdapter.setDatas(initDatas());

// indexableLayout.setOverlayStyle_MaterialDesign(Color.RED); 设置提示框为仿联系人气泡样式

// 全字母排序。排序规则设置为:每个字母都会进行比较排序;速度较慢

indexableLayout.setCompareMode(IndexableLayout.MODE_FAST);

// indexableLayout.addHeaderAdapter(new SimpleHeaderAdapter<>(mAdapter, “☆”,null, null));

// 构造函数里3个参数,分别对应 (IndexBar的字母索引, IndexTitle, 数据源), 不想显示哪个就传null, 数据源传null时,代表add一个普通的View

// mMenuHeaderAdapter = new MenuHeaderAdapter(“↑”, null, initMenuDatas());

// indexableLayout.addHeaderAdapter(mMenuHeaderAdapter);

// 这里BannerView只有一个Item, 添加一个长度为1的任意List作为第三个参数

List bannerList = new ArrayList<>();

bannerList.add(“”);

mBannerHeaderAdapter = new BannerHeaderAdapter(“↑”, null, bannerList);

indexableLayout.addHeaderAdapter(mBannerHeaderAdapter);

}

public void initview(){

intent = getIntent();

pic_contact_back = (ImageView) findViewById(R.id.pic_contact_back);

indexableLayout = (IndexableLayout) findViewById(R.id.indexableLayout);

indexableLayout.setLayoutManager(new LinearLayoutManager(this));

}

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 IndexableH

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值