Android从底部弹出的多选弹窗

github地址: https://github.com/Jay-Goo/MultiSelectPopWindow

image.png

gradle(主项目)

allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
}

gradle(app)

//解决依赖冲突
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '27.1.1'
}
}
}
}
dependencies {
...
compile 'com.github.Jay-Goo:MultiSelectPopWindow:v1.0.1'
}

使用说明:

 new MultiSelectPopWindow.Builder(MainActivity.this)
.setTitle("班级列表1")
.setConfirm("确定")
.setCancel("取消")
.setNameArray(list2)
.setCancelListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

    }
})
.setConfirmListener(new MultiSelectPopWindow.OnConfirmClickListener() {
    @Override
    public void onClick(ArrayList<Integer> indexList, ArrayList<String> selectedList) {
        Log.d(TAG, indexList.size() + "," + selectedList.size());
        for (int i = 0; i < indexList.size(); i++) {
            Log.d(TAG, indexList.get(i) + "_" + selectedList.get(i));
        }
    }
})
.build()
.show(findViewById(R.id.bottom));

注意:MultiSelectPopWindow必须在某个控件的上方,也就是必须
.show(findViewById(R.id.bottom))

见布局activity_main.xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.cqc.mulitiseletpopupwindow01.MainActivity">

<Button
    android:id="@+id/btn1"
    android:text="打开PopupWindow"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>


<Space
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"/>
<View
    android:id="@+id/bottom"
    android:layout_width="match_parent"
    android:layout_height="1dp"/>
    </LinearLayout>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Gradle配置最佳实践 本文会不定期更新,推荐watch下项目。如果喜欢请star,如果觉得有纰漏请提交issu...
    Solang阅读 1,651评论 0 4
  • 第一个问题: 在项目的build.gradle文件里面 Cannot set the value of read-...
    正阳Android阅读 3,071评论 2 2
  • 请允许我借鉴前辈们的东西~~~~ 感激不尽~~~~~ 以下为Android 框架排行榜 么么哒~ Android...
    嗯_新阅读 2,110评论 3 32
  • 1 ,Android 构建系统 构建 APK 的过程是个相当复杂的过程,Android 构建系统需要将应用的资源文...
    8ba406212441阅读 1,447评论 0 1
  • 上午加了五个,完成上午目标 下午加了13个一个没通过一个把我删除 看到自己被删掉,心里很难受,毕竟是自己辛辛苦苦加...
    70325df2ab01阅读 148评论 0 0