当前位置:网站首页>直播软件搭建,流式布局,支持单选、多选等
直播软件搭建,流式布局,支持单选、多选等
2022-08-11 03:58:00 【云豹网络科技】
直播软件搭建,流式布局,支持单选、多选等
用法:
dependencies {
compile 'com.hyman:flowlayout-lib:1.1.2'
}
布局:
<!--max_select:-1为不限制选择数量,>=1的数字为控制选择tag的数量-->
<com.zhy.view.flowlayout.TagFlowLayout
android:id="@+id/id_flowlayout"
zhy:max_select="-1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp">
</com.zhy.view.flowlayout.TagFlowLayout>
代码:
public class FlowlayoutActivity extends AppCompatActivity {
TagFlowLayout tagFlowLayout;
private List<String> list;
private LayoutInflater layoutInflater;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.flowlayout_activity);
private void initView(){
layoutInflater = LayoutInflater.from(this);
tagFlowLayout = findViewById(R.id.id_flowlayout);
tagFlowLayout.setAdapter(new TagAdapter<String>(list)
{
@Override
public View getView(FlowLayout parent, int position, String s)
{
TextView tv = (TextView) layoutInflater.inflate(R.layout.flowlayout_item_tv,
tagFlowLayout, false);
tv.setText(s);
return tv;
}
});
tagFlowLayout.setOnTagClickListener(new TagFlowLayout.OnTagClickListener()
{
@Override
public boolean onTagClick(View view, int position, FlowLayout parent)
{
//得到点击的值
Toast.makeText(getApplicationContext(), list.get(position), Toast.LENGTH_SHORT).show();
return true;
}
});
tagFlowLayout.setOnSelectListener(new TagFlowLayout.OnSelectListener() {
@Override
public void onSelected(Set<Integer> selectPosSet) {
Log.i("得到下标的集合",selectPosSet.toString());
//得到下标的集合
//Toast.makeText(getApplicationContext(), selectPosSet.toString()+"s", Toast.LENGTH_SHORT).show();
}
});
/*//预先设置选中 mAdapter.setSelectedList(1,3,5,7,8,9); //获得所有选中的pos集合 flowLayout.getSelectedList();*/
}
}
以上就是 直播软件搭建,流式布局,支持单选、多选等,更多内容欢迎关注之后的文章
边栏推荐
猜你喜欢
机器学习怎么学?机器学习流程
Provincial level of Echart maps, as well as all prefecture-level download and use
Interchangeability and Measurement Technology—Surface Roughness Selection and Marking Method
2022-08-10 The sixth group Hiding spring study notes
Where can machine learning be applied?What is machine learning useful for?
LeetCode刷题第12天二叉树系列之《104 二叉树的最大深度》
Redis老了吗?Redis与Dragonfly性能比较
es-head plugin insert query and conditional query (5)
Interchangeable Measurement Techniques - Geometric Errors
(转)JVM中那些区域会发生OOM?
随机推荐
EasyCVR接入GB28181设备时,设备接入正常但视频无法播放是什么原因?
The thirteenth day of learning programming
set_new_handler(0)是什么意思?有什么用?
Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
Leetcode 669. 修剪二叉搜索树
Qnet Weak Network Test Tool Operation Guide
leetcode刷题第13天二叉树系列之《98 BST及其验证》
Binary tree related code questions [more complete] C language
.NET自定义中间件
Callable实现多线程
Will oracle cardinality affect query speed?
Power Cabinet Data Monitoring RTU
拼多多店铺营业执照相关问题
.NET service registration
When EasyCVR is connected to the GB28181 device, what is the reason that the device is connected normally but the video cannot be played?
LeetCode刷题第10天字符串系列之《125回文串验证》
学编程的第十三天
UNI-APP_iphone bottom safe area
Alibaba Cloud releases 3 high-performance computing solutions
C语言 recv()函数、recvfrom()函数、recvmsg()函数