├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── why │ │ └── project │ │ └── spinnerviewpopdemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── spinners.txt │ │ ├── spinners2.txt │ │ ├── spinners3.txt │ │ └── spinners4.txt │ ├── java │ │ └── com │ │ │ └── why │ │ │ └── project │ │ │ └── spinnerviewpopdemo │ │ │ ├── MainActivity.java │ │ │ ├── bean │ │ │ └── SpinnearBean.java │ │ │ └── views │ │ │ └── spinner │ │ │ ├── SpinnerViewMultiDialog.java │ │ │ ├── SpinnerViewPop.java │ │ │ ├── adapter │ │ │ ├── MySpinnerPopListArrayAdapter.java │ │ │ └── MySpinnerPopMultListArrayAdapter.java │ │ │ ├── listener │ │ │ ├── OnSpinnerClickListener.java │ │ │ ├── OnSpinnerConfirmClickListener.java │ │ │ └── OnSpinnerItemClickListener.java │ │ │ └── util │ │ │ ├── DialogUtil.java │ │ │ └── PopWindowUtil.java │ └── res │ │ ├── drawable-xxhdpi │ │ ├── spinnerview_pop_icon_ck_normal.png │ │ ├── spinnerview_pop_icon_ck_selected.png │ │ ├── spinnerview_pop_icon_shang.png │ │ ├── spinnerview_pop_icon_xia.png │ │ └── spinnerview_pop_list_line.png │ │ ├── drawable │ │ ├── spinnerview_pop_box_bg_drawable.xml │ │ ├── spinnerview_pop_list_bg_drawable.xml │ │ └── spinnerview_pop_listitem_bg_drawable.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── spinnerview_pop_list_item.xml │ │ ├── spinnerview_pop_list_item_mult.xml │ │ ├── spinnerview_pop_list_layout.xml │ │ ├── spinnerview_pop_list_layout_mult.xml │ │ └── spinnerview_pop_view.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── why │ └── project │ └── spinnerviewpopdemo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── 安装包 └── app-debug.apk /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SpinnerViewPopDemo 2 | [SpinnerViewPop【PopWindow样式(单选)、Dialog样式(单选+多选)的下拉菜单】](http://www.cnblogs.com/whycxb/p/7251720.html) 3 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.3" 6 | defaultConfig { 7 | applicationId "com.why.project.spinnerviewpopdemo" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | testCompile 'junit:junit:4.12' 29 | } 30 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\software\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/why/project/spinnerviewpopdemo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.why.project.spinnerviewpopdemo; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.why.project.spinnerviewpopdemo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/assets/spinners.txt: -------------------------------------------------------------------------------- 1 | { 2 | "spinnerList": [ 3 | { 4 | "paraName": "天", 5 | "paraValue": "day" 6 | }, 7 | { 8 | "paraName": "周", 9 | "paraValue": "week" 10 | }, 11 | { 12 | "paraName": "月", 13 | "paraValue": "month" 14 | }, 15 | { 16 | "paraName": "年", 17 | "paraValue": "year" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /app/src/main/assets/spinners2.txt: -------------------------------------------------------------------------------- 1 | { 2 | "spinnerList": [ 3 | { 4 | "paraName": "红色", 5 | "paraValue": "red", 6 | "checkColor": "#FF0000" 7 | }, 8 | { 9 | "paraName": "绿色", 10 | "paraValue": "green", 11 | "checkColor": "#00FF00" 12 | }, 13 | { 14 | "paraName": "黄色", 15 | "paraValue": "yellow", 16 | "checkColor": "#FFFF00" 17 | }, 18 | { 19 | "paraName": "蓝色", 20 | "paraValue": "blue", 21 | "checkColor": "#0000FF" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /app/src/main/assets/spinners3.txt: -------------------------------------------------------------------------------- 1 | { 2 | "spinnerList": [ 3 | { 4 | "paraName": "男", 5 | "paraValue": "boy" 6 | }, 7 | { 8 | "paraName": "女", 9 | "paraValue": "girl" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /app/src/main/assets/spinners4.txt: -------------------------------------------------------------------------------- 1 | { 2 | "spinnerList": [ 3 | { 4 | "paraName": "乒乓球", 5 | "paraValue": "Pingpong" 6 | }, 7 | { 8 | "paraName": "羽毛球", 9 | "paraValue": "Badminton" 10 | }, 11 | { 12 | "paraName": "台球", 13 | "paraValue": "Billiards" 14 | }, 15 | { 16 | "paraName": "篮球", 17 | "paraValue": "Basketball" 18 | }, 19 | { 20 | "paraName": "足球", 21 | "paraValue": "Football" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /app/src/main/java/com/why/project/spinnerviewpopdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.why.project.spinnerviewpopdemo; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.widget.TextView; 7 | import android.widget.Toast; 8 | 9 | import com.why.project.spinnerviewpopdemo.bean.SpinnearBean; 10 | import com.why.project.spinnerviewpopdemo.views.spinner.listener.OnSpinnerClickListener; 11 | import com.why.project.spinnerviewpopdemo.views.spinner.listener.OnSpinnerConfirmClickListener; 12 | import com.why.project.spinnerviewpopdemo.views.spinner.listener.OnSpinnerItemClickListener; 13 | import com.why.project.spinnerviewpopdemo.views.spinner.SpinnerViewMultiDialog; 14 | import com.why.project.spinnerviewpopdemo.views.spinner.SpinnerViewPop; 15 | 16 | import org.json.JSONArray; 17 | import org.json.JSONObject; 18 | 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.InputStream; 21 | import java.util.ArrayList; 22 | 23 | import static com.why.project.spinnerviewpopdemo.R.id.spinnerView_pop0; 24 | import static com.why.project.spinnerviewpopdemo.R.id.spinnerView_pop1; 25 | import static com.why.project.spinnerviewpopdemo.R.id.spinnerView_pop2; 26 | import static com.why.project.spinnerviewpopdemo.R.id.spinnerView_pop3; 27 | 28 | public class MainActivity extends AppCompatActivity { 29 | 30 | private SpinnerViewPop spinnerView_notEditable; 31 | 32 | private SpinnerViewPop spinnerView_pop; 33 | /**下拉菜单列表集合*/ 34 | private ArrayList mSpinner1List; 35 | 36 | private SpinnerViewPop spinnerView_pop_bgcolor; 37 | /**下拉菜单列表集合*/ 38 | private ArrayList mSpinner2List; 39 | 40 | private SpinnerViewPop spinnerView_radioDialog; 41 | /**下拉菜单列表集合*/ 42 | private ArrayList mSpinner3List; 43 | 44 | private SpinnerViewMultiDialog spinnerView_multDialog; 45 | /**下拉菜单列表集合*/ 46 | private ArrayList mSpinner4List; 47 | 48 | private TextView tv_show; 49 | 50 | @Override 51 | protected void onCreate(Bundle savedInstanceState) { 52 | super.onCreate(savedInstanceState); 53 | setContentView(R.layout.activity_main); 54 | 55 | initViews(); 56 | initDatas(); 57 | initEvents(); 58 | } 59 | 60 | private void initViews() { 61 | 62 | spinnerView_notEditable = (SpinnerViewPop) findViewById(spinnerView_pop0); 63 | spinnerView_notEditable.setEditable(false);//禁用下拉菜单区域 64 | 65 | spinnerView_pop = (SpinnerViewPop) findViewById(spinnerView_pop1); 66 | spinnerView_pop.setHandedPopup(true);//实现点击下拉菜单区域触发事件,一般用来隐藏软键盘,或者网络请求,最后手动弹出下拉菜单 67 | 68 | spinnerView_pop_bgcolor = (SpinnerViewPop) findViewById(spinnerView_pop2); 69 | 70 | spinnerView_radioDialog = (SpinnerViewPop) findViewById(spinnerView_pop3); 71 | spinnerView_radioDialog.setSpinnerType(SpinnerViewPop.TYPE_DIALOG);//设置对话框样式,默认为popwindow样式 72 | 73 | spinnerView_multDialog = (SpinnerViewMultiDialog) findViewById(R.id.spinnerView_pop4); 74 | 75 | tv_show = (TextView) findViewById(R.id.tv_show); 76 | 77 | } 78 | 79 | private void initDatas() { 80 | /*==============================普通下拉菜单列表项=========================================*/ 81 | mSpinner1List = new ArrayList(); 82 | //模拟获取数据集合 83 | try{ 84 | mSpinner1List = parseJsonArray("spinners.txt"); 85 | }catch (Exception e) { 86 | e.printStackTrace(); 87 | } 88 | //设置下拉菜单显示的列表项文本 89 | if (mSpinner1List != null && mSpinner1List.size() > 0){ 90 | spinnerView_pop.setData(mSpinner1List);//设置下拉菜单列表集合源 91 | spinnerView_pop.setSelectedIndexAndText(0);//更改下拉菜单选中的列表项下标值 92 | } 93 | /*==============================下拉菜单列表项带有背景颜色=========================================*/ 94 | mSpinner2List = new ArrayList(); 95 | //模拟获取数据集合 96 | try{ 97 | mSpinner2List = parseJsonArray("spinners2.txt"); 98 | }catch (Exception e) { 99 | e.printStackTrace(); 100 | } 101 | //设置下拉菜单显示的列表项文本 102 | if (mSpinner2List != null && mSpinner2List.size() > 0){ 103 | spinnerView_pop_bgcolor.setData(mSpinner2List);//设置下拉菜单列表集合源 104 | spinnerView_pop_bgcolor.setSelectedIndexAndText(0);//更改下拉菜单选中的列表项下标值 105 | } 106 | 107 | /*==============================下拉菜单列表项单选对话框=========================================*/ 108 | mSpinner3List = new ArrayList(); 109 | //模拟获取数据集合 110 | try{ 111 | mSpinner3List = parseJsonArray("spinners3.txt"); 112 | }catch (Exception e) { 113 | e.printStackTrace(); 114 | } 115 | //设置下拉菜单显示的列表项文本 116 | if (mSpinner3List != null && mSpinner3List.size() > 0){ 117 | spinnerView_radioDialog.setData(mSpinner3List);//设置下拉菜单列表集合源 118 | spinnerView_radioDialog.setSelectedIndexAndText(0);//更改下拉菜单选中的列表项下标值 119 | } 120 | 121 | /*==============================下拉菜单列表项多选对话框=========================================*/ 122 | mSpinner4List = new ArrayList(); 123 | //模拟获取数据集合 124 | try{ 125 | mSpinner4List = parseJsonArray("spinners4.txt"); 126 | }catch (Exception e) { 127 | e.printStackTrace(); 128 | } 129 | //设置下拉菜单显示的列表项文本 130 | if (mSpinner4List != null && mSpinner4List.size() > 0){ 131 | spinnerView_multDialog.setData(mSpinner4List);//设置下拉菜单列表集合源 132 | spinnerView_multDialog.setHint("选择你的爱好"); 133 | } 134 | 135 | } 136 | 137 | private void initEvents() { 138 | 139 | //下拉菜单区域的点击事件监听 140 | spinnerView_pop.setOnSpinnerClickListener(new OnSpinnerClickListener() { 141 | @Override 142 | public void OnFinished() { 143 | //KeyboardUtil.hideKeyboard(MainActivity.this);//隐藏软键盘 144 | spinnerView_pop.PopupListDialog(); 145 | } 146 | }); 147 | //下拉菜单列表的列表项的点击事件监听 148 | spinnerView_pop.setOnSpinnerItemClickListener(new OnSpinnerItemClickListener() { 149 | @Override 150 | public void OnFinished(int position) { 151 | tv_show.setText(mSpinner1List.get(position).getParaName() + ":" + mSpinner1List.get(position).getParaValue()); 152 | StringBuffer str = new StringBuffer(); 153 | for(int i=0;i selecteIndexList) { 190 | StringBuffer str1 = new StringBuffer(); 191 | for(int i=0;i parseJsonArray(String fileName) throws Exception{ 219 | 220 | ArrayList itemsList = new ArrayList(); 221 | 222 | String jsonStr = getStringFromAssert(MainActivity.this, fileName); 223 | if(jsonStr.equals("")){ 224 | return null; 225 | } 226 | JSONObject allData = new JSONObject(jsonStr); //全部内容变为一个项 227 | JSONArray jsonArr = allData.getJSONArray(LISTROOTNODE); //取出数组 228 | for(int x = 0;x mTitleTextList = null;//原始类型为String 35 | 36 | /**下拉菜单区域的点击事件:用于显示下拉菜单对话框*/ 37 | private OnSpinnerClickListener listener = null; 38 | /**列表对话框的确定文本的点击事件:用于将选中的列表项赋值给下拉菜单区域*/ 39 | private OnSpinnerConfirmClickListener itemListener = null; 40 | 41 | /**对话框是否隐藏的状态值*/ 42 | private boolean handedPop = false; 43 | /**上下文,用于展现对话框的载体*/ 44 | private Context mContext; 45 | private ArrayList selecteIndexList; 46 | 47 | /**下拉菜单是否可编辑*/ 48 | private boolean canEditable = true; 49 | /**文本的颜色:默认黑色*/ 50 | private int textDefaultColor = 0; 51 | 52 | /** 53 | * 这里构造方法也很重要,不加这个很多属性不能再XML里面定义*/ 54 | public SpinnerViewMultiDialog(Context context, AttributeSet attrs) { 55 | super(context, attrs); 56 | 57 | mContext = context; 58 | //引用布局:一个文本和右侧的图标 59 | LayoutInflater.from(context).inflate(R.layout.spinnerview_pop_view, this, true); 60 | 61 | //获取textview对象,并设置点击的监听事件——判断 62 | titleTextView = (TextView) findViewById(R.id.titleTextView); 63 | textDefaultColor = getResources().getColor(R.color.spinnerpop_normal_text_color); 64 | //默认文本颜色 65 | titleTextView.setTextColor(textDefaultColor); 66 | titleTextView.setOnClickListener(new View.OnClickListener() { 67 | @Override 68 | public void onClick(View v) { 69 | //弹出对话框 70 | if(canEditable){ 71 | if (handedPop) { 72 | listener.OnFinished(); 73 | } else { 74 | PopupListDialog(); 75 | } 76 | } 77 | } 78 | }); 79 | } 80 | 81 | /** 82 | * 弹出列表对话框*/ 83 | public void PopupListDialog() { 84 | 85 | showSelectedState(true);//设置下拉菜单文本框为选中/默认样式 86 | 87 | if (null == mTitleTextList) { 88 | mTitleTextList = new ArrayList(); 89 | } 90 | 91 | MySpinnerPopMultListArrayAdapter.OnMyMultItemClickListener multItemClickListener = new MySpinnerPopMultListArrayAdapter.OnMyMultItemClickListener() { 92 | @Override 93 | public void OnMyMultItemClick(ArrayList selecteIndexList) { 94 | //如果position == -1,标明是点击弹出框外面的区域 95 | if(selecteIndexList.size() > 0){ 96 | DialogUtil.closeDialog();//关闭列表对话框 97 | //将选中状态的列表项的选中状态赋值到model类中 98 | setSelectedIndexAndText(selecteIndexList); 99 | 100 | if (null != itemListener) { 101 | itemListener.OnConfirmed(selecteIndexList); 102 | } 103 | } 104 | showSelectedState(false);//设置下拉菜单文本框为选中/默认样式 105 | } 106 | }; 107 | 108 | //原始类型为String 109 | ArrayList itemTextList = new ArrayList(); 110 | for(int i=0;i mArrayList) { 118 | this.mTitleTextList = mArrayList; 119 | } 120 | 121 | /**设置选中的下标值以及文本以及SpinnearModel中的选中状态值*/ 122 | public void setSelectedIndexAndText(ArrayList selecteIndexList){ 123 | 124 | StringBuffer selectedNames = new StringBuffer(); 125 | for(int i=0;i getSelecteIndexList() { 156 | return selecteIndexList; 157 | } 158 | 159 | //设置文本颜色 160 | public void setTextColor(int color){ 161 | textDefaultColor = color; 162 | titleTextView.setTextColor(textDefaultColor); 163 | } 164 | //设置提示语 165 | public void setHint(String hint) { 166 | titleTextView.setHint(hint); 167 | } 168 | 169 | //设置右侧的图标 170 | private void setDrawableRight(Drawable rightIcon) { 171 | rightIcon.setBounds(0, 0, rightIcon.getMinimumWidth(), rightIcon.getMinimumHeight()); 172 | titleTextView.setCompoundDrawables(null, null, rightIcon, null); 173 | } 174 | 175 | /*===========================是否展现选中状态===========================*/ 176 | private void showSelectedState(boolean isSelected){ 177 | //选中状态 178 | if(isSelected){ 179 | //修改箭头图标 180 | setDrawableRight(ContextCompat.getDrawable(mContext,R.drawable.spinnerview_pop_icon_shang)); 181 | //修改文本颜色 182 | titleTextView.setTextColor(getResources().getColor(R.color.spinnerpop_selected_text_color)); 183 | }else{ 184 | //修改箭头图标 185 | setDrawableRight(ContextCompat.getDrawable(mContext,R.drawable.spinnerview_pop_icon_xia)); 186 | //修改文本颜色 187 | titleTextView.setTextColor(textDefaultColor); 188 | } 189 | } 190 | 191 | /** 192 | * 设置是否可编辑*/ 193 | public void setEditable(boolean canEdit){ 194 | canEditable = canEdit; 195 | if(canEditable){ 196 | //修改背景颜色--白色 197 | //在使用shape的同时,用代码修改shape的颜色属性http://blog.csdn.net/wangdong20/article/details/37966333 198 | GradientDrawable myGrad = (GradientDrawable)getBackground(); 199 | myGrad.setColor(ContextCompat.getColor(mContext,R.color.spinnerpop_canedit_bg_color)); 200 | }else{ 201 | //修改背景颜色--灰色 202 | GradientDrawable myGrad = (GradientDrawable)getBackground(); 203 | myGrad.setColor(ContextCompat.getColor(mContext,R.color.spinnerpop_notedit_bg_color)); 204 | } 205 | } 206 | 207 | } 208 | -------------------------------------------------------------------------------- /app/src/main/java/com/why/project/spinnerviewpopdemo/views/spinner/SpinnerViewPop.java: -------------------------------------------------------------------------------- 1 | package com.why.project.spinnerviewpopdemo.views.spinner; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.Drawable; 5 | import android.graphics.drawable.GradientDrawable; 6 | import android.support.v4.content.ContextCompat; 7 | import android.util.AttributeSet; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.widget.RelativeLayout; 11 | import android.widget.TextView; 12 | 13 | import com.why.project.spinnerviewpopdemo.R; 14 | import com.why.project.spinnerviewpopdemo.bean.SpinnearBean; 15 | import com.why.project.spinnerviewpopdemo.views.spinner.adapter.MySpinnerPopListArrayAdapter; 16 | import com.why.project.spinnerviewpopdemo.views.spinner.listener.OnSpinnerClickListener; 17 | import com.why.project.spinnerviewpopdemo.views.spinner.listener.OnSpinnerItemClickListener; 18 | import com.why.project.spinnerviewpopdemo.views.spinner.util.DialogUtil; 19 | import com.why.project.spinnerviewpopdemo.views.spinner.util.PopWindowUtil; 20 | 21 | import java.util.ArrayList; 22 | 23 | /** 24 | * @Created HaiyuKing 25 | * @Used 下拉菜单区域:自定义——继承RelativeLayout 26 | */ 27 | public class SpinnerViewPop extends RelativeLayout { 28 | /**下拉菜单文本区域*/ 29 | private TextView titleTextView; 30 | /**接收传递过来的列表项文本集合*/ 31 | private ArrayList mTitleTextList = null;//原始类型为String 32 | 33 | /**下拉菜单区域的点击事件:用于显示下拉菜单对话框*/ 34 | private OnSpinnerClickListener listener = null; 35 | /**列表对话框的列表项点击事件:用于将选中的列表项赋值给下拉菜单区域*/ 36 | private OnSpinnerItemClickListener itemListener = null; 37 | 38 | /**是否执行下拉菜单区域的点击事件监听的状态值,默认为false(直接打开下拉菜单),如果为true的话,则先执行点击事件监听,搭配OnSpinnerClickListener使用*/ 39 | private boolean handedPop = false; 40 | /**上下文,用于展现对话框的载体*/ 41 | private Context mContext; 42 | /**选中的列表项的下标值*/ 43 | private int selecteItem = 0; 44 | 45 | /**下拉菜单是否可编辑*/ 46 | private boolean canEditable = true; 47 | /**文本的颜色:默认黑色*/ 48 | private int textDefaultColor = 0; 49 | 50 | public static final String TYPE_POPWINDOW = "popwindow";//popwindow样式下拉菜单 51 | public static final String TYPE_DIALOG = "radiodialog";//单选下拉菜单对话框 52 | 53 | /**下拉菜单的类型:popwindow 或者 dialog*/ 54 | private String spinnerType = TYPE_POPWINDOW; 55 | 56 | /** 57 | * 这里构造方法也很重要,不加这个很多属性不能再XML里面定义*/ 58 | public SpinnerViewPop(Context context, AttributeSet attrs) { 59 | super(context, attrs); 60 | 61 | mContext = context; 62 | //引用布局:一个文本和右侧的图标 63 | LayoutInflater.from(context).inflate(R.layout.spinnerview_pop_view, this, true); 64 | 65 | //获取textview对象,并设置点击的监听事件——判断 66 | titleTextView = (TextView) findViewById(R.id.titleTextView); 67 | textDefaultColor = getResources().getColor(R.color.spinnerpop_normal_text_color); 68 | //默认文本颜色 69 | titleTextView.setTextColor(textDefaultColor); 70 | titleTextView.setOnClickListener(new OnClickListener() { 71 | @Override 72 | public void onClick(View v) { 73 | //弹出对话框 74 | if(canEditable){ 75 | if (handedPop) { 76 | listener.OnFinished(); 77 | } else { 78 | PopupListDialog(); 79 | } 80 | } 81 | } 82 | }); 83 | } 84 | 85 | /** 86 | * 弹出列表对话框*/ 87 | public void PopupListDialog() { 88 | 89 | showSelectedState(true);//设置下拉菜单文本框为选中/默认样式 90 | 91 | if (null == mTitleTextList) { 92 | mTitleTextList = new ArrayList(); 93 | } 94 | 95 | //自定义列表项的点击事件监听——在MySpinnerListArrayAdapter类中自定义的接口 96 | MySpinnerPopListArrayAdapter.OnMyItemClickListener itemClickListener = new MySpinnerPopListArrayAdapter.OnMyItemClickListener() { 97 | @Override 98 | public void OnMyItemClick(int position) { 99 | //如果position == -1,标明是点击弹出框外面的区域 100 | if(position != -1){ 101 | if(spinnerType.equals(TYPE_POPWINDOW)){ 102 | PopWindowUtil.closePopupWindows();//关闭列表对话框 103 | }else{ 104 | DialogUtil.closeDialog();//关闭列表对话框 105 | } 106 | //此处需要判断,如果是多选对话框的话,需要特殊处理 107 | setSelectedIndexAndText(position); 108 | 109 | if (null != itemListener) { 110 | itemListener.OnFinished(position); 111 | } 112 | } 113 | showSelectedState(false);//设置下拉菜单文本框为选中/默认样式 114 | } 115 | }; 116 | 117 | //原始类型为String 118 | ArrayList itemTextList = new ArrayList(); 119 | for(int i=0;i mArrayList) { 131 | this.mTitleTextList = mArrayList; 132 | } 133 | 134 | /**设置选中的下标值以及文本以及SpinnearModel中的选中状态值*/ 135 | public void setSelectedIndexAndText(int index){ 136 | titleTextView.setText(mTitleTextList.get(index).getParaName().toString()); 137 | selecteItem = index; 138 | for(int i = 0;i{ 27 | 28 | private Context mcontext; 29 | private int listitemResourceid;//列表项的布局文件ID 30 | private int selecteIndex;//选中列表项的下标值 31 | /** 32 | * 重写构造函数,获取列表项布局文件ID*/ 33 | public MySpinnerPopListArrayAdapter(Context context, int resource, 34 | List objects, int selecteItem) { 35 | super(context, resource, objects); 36 | listitemResourceid = resource; 37 | mcontext = context; 38 | selecteIndex = selecteItem; 39 | } 40 | 41 | /** 42 | * 重写getView*/ 43 | public View getView(int position, View convertView, ViewGroup parent) { 44 | 45 | SpinnearBean listitem = getItem(position); 46 | final int index = position; 47 | final ViewHolder holder; 48 | View view; 49 | if(convertView == null){ 50 | view = LayoutInflater.from(mcontext).inflate(listitemResourceid, parent, false); 51 | holder = new ViewHolder(); 52 | holder.listitemText = (TextView) view.findViewById(R.id.listitemText); 53 | view.setTag(holder); 54 | }else{ 55 | view = convertView; 56 | holder = (ViewHolder) view.getTag(); 57 | } 58 | 59 | holder.listitemText.setText((CharSequence) listitem.getParaName()); 60 | 61 | //列表项的点击事件 62 | view.setOnClickListener(new OnClickListener() { 63 | public void onClick(View arg0) { 64 | if(onMyItemClickListener != null){ 65 | onMyItemClickListener.OnMyItemClick(index);//执行Activity界面中的方法 66 | } 67 | } 68 | }); 69 | 70 | //如果选中的下标值等于当前下标值,则修改文本颜色为选中样式 71 | if(selecteIndex == position){ 72 | holder.listitemText.setTextColor(getContext().getResources().getColor(R.color.spinnerpop_selected_text_color)); 73 | }else{ 74 | holder.listitemText.setTextColor(getContext().getResources().getColor(R.color.spinnerpop_normal_text_color)); 75 | } 76 | 77 | if(! listitem.getCheckColor().equals("noData")){ 78 | //如果checkColor有赋值后的数据,则执行下面的代码 79 | String checkColor = listitem.getCheckColor(); 80 | 81 | //获取xml里设置的statelistdrawable内的各个状态对应的drawable http://blog.csdn.net/ni357103403/article/details/50402253 82 | StateListDrawable mySelectorGrad = (StateListDrawable)view.getBackground(); 83 | 84 | try { 85 | Class slDraClass = StateListDrawable.class; 86 | Method getStateCountMethod = slDraClass.getDeclaredMethod("getStateCount", new Class[0]); 87 | Method getStateSetMethod = slDraClass.getDeclaredMethod("getStateSet", int.class); 88 | Method getDrawableMethod = slDraClass.getDeclaredMethod("getStateDrawable", int.class); 89 | int count = (Integer) getStateCountMethod.invoke(mySelectorGrad, new Object[]{});//对应item标签 90 | Log.d(TAG, "state count ="+count); 91 | for(int i=0;i < count;i++) { 92 | int[] stateSet = (int[]) getStateSetMethod.invoke(mySelectorGrad, i);//对应item标签中的 android:state_xxxx 93 | if (stateSet == null || stateSet.length == 0) { 94 | Log.d(TAG, "state is null"); 95 | GradientDrawable drawable = (GradientDrawable) getDrawableMethod.invoke(mySelectorGrad, i);//这就是你要获得的Enabled为false时候的drawable 96 | drawable.setColor(Color.parseColor(checkColor)); 97 | } else { 98 | for (int j = 0; j < stateSet.length; j++) { 99 | Log.d(TAG, "state =" + stateSet[j]); 100 | Drawable drawable = (Drawable) getDrawableMethod.invoke(mySelectorGrad, i);//这就是你要获得的Enabled为false时候的drawable 101 | } 102 | } 103 | } 104 | } catch (NoSuchMethodException e) { 105 | e.printStackTrace(); 106 | } catch (InvocationTargetException e) { 107 | e.printStackTrace(); 108 | } catch (IllegalAccessException e) { 109 | e.printStackTrace(); 110 | } 111 | } 112 | 113 | return view; 114 | } 115 | //添加static 解决Type safety: Unchecked cast from Object to MySpinnerListArrayAdapter.ViewHolder 116 | static class ViewHolder{ 117 | 118 | TextView listitemText; 119 | } 120 | 121 | //列表项的单击事件监听接口 122 | public interface OnMyItemClickListener{ 123 | void OnMyItemClick(int position); 124 | } 125 | 126 | public void setOnMyItemClickListener(OnMyItemClickListener onMyItemClickListener){ 127 | this.onMyItemClickListener = onMyItemClickListener; 128 | } 129 | 130 | private OnMyItemClickListener onMyItemClickListener; 131 | } 132 | -------------------------------------------------------------------------------- /app/src/main/java/com/why/project/spinnerviewpopdemo/views/spinner/adapter/MySpinnerPopMultListArrayAdapter.java: -------------------------------------------------------------------------------- 1 | package com.why.project.spinnerviewpopdemo.views.spinner.adapter; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.Drawable; 5 | import android.support.v4.content.ContextCompat; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ArrayAdapter; 10 | import android.widget.CheckedTextView; 11 | 12 | import com.why.project.spinnerviewpopdemo.R; 13 | import com.why.project.spinnerviewpopdemo.bean.SpinnearBean; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | 19 | /** 20 | * Created by HaiyuKing 21 | * Used 多选对话框的适配器 22 | */ 23 | 24 | public class MySpinnerPopMultListArrayAdapter extends ArrayAdapter { 25 | 26 | private Context mcontext; 27 | private int listitemResourceid;//列表项的布局文件ID 28 | private ArrayList selecteIndex;//列表项的下标值集合,用于存储选中状态 29 | /** 30 | * 重写构造函数,获取列表项布局文件ID*/ 31 | public MySpinnerPopMultListArrayAdapter(Context context, int resource, 32 | List objects) { 33 | super(context, resource, objects); 34 | listitemResourceid = resource; 35 | mcontext = context; 36 | 37 | selecteIndex = new ArrayList(); 38 | if(objects.size() > 0){ 39 | for(int i=0;i.ViewHolder 90 | static class ViewHolder{ 91 | 92 | CheckedTextView id_checkedTextView; 93 | } 94 | 95 | /**更换选中状态的图标*/ 96 | private void setSelectedState(CheckedTextView view, boolean selected){ 97 | view.setSelected(selected);//关键 98 | 99 | if(selected){ 100 | //设置CheckedTextView控件的android:drawableTop属性值 101 | Drawable drawable = ContextCompat.getDrawable(mcontext, R.drawable.spinnerview_pop_icon_ck_selected); 102 | //setCompoundDrawables 画的drawable的宽高是按drawable.setBound()设置的宽高 103 | //而setCompoundDrawablesWithIntrinsicBounds是画的drawable的宽高是按drawable固定的宽高,即通过getIntrinsicWidth()与getIntrinsicHeight()自动获得 104 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); 105 | view.setCompoundDrawables(null, null, drawable, null); 106 | }else{ 107 | //设置CheckedTextView控件的android:drawableTop属性值 108 | Drawable drawable = ContextCompat.getDrawable(mcontext, R.drawable.spinnerview_pop_icon_ck_normal); 109 | //setCompoundDrawables 画的drawable的宽高是按drawable.setBound()设置的宽高 110 | //而setCompoundDrawablesWithIntrinsicBounds是画的drawable的宽高是按drawable固定的宽高,即通过getIntrinsicWidth()与getIntrinsicHeight()自动获得 111 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); 112 | view.setCompoundDrawables(null, null, drawable, null); 113 | } 114 | } 115 | 116 | public ArrayList getSelecteIndex() { 117 | return selecteIndex; 118 | } 119 | 120 | //列表项的单击事件监听接口 121 | public interface OnMyMultItemClickListener{ 122 | void OnMyMultItemClick(ArrayList selecteIndexList); 123 | } 124 | 125 | public void setOnMyItemClickListener(OnMyMultItemClickListener onMyMultItemClickListener){ 126 | this.onMyMultItemClickListener = onMyMultItemClickListener; 127 | } 128 | 129 | private OnMyMultItemClickListener onMyMultItemClickListener; 130 | } 131 | -------------------------------------------------------------------------------- /app/src/main/java/com/why/project/spinnerviewpopdemo/views/spinner/listener/OnSpinnerClickListener.java: -------------------------------------------------------------------------------- 1 | package com.why.project.spinnerviewpopdemo.views.spinner.listener; 2 | 3 | /** 4 | * @Created HaiyuKing 5 | * @Used 下拉菜单区域点击事件 6 | */ 7 | public interface OnSpinnerClickListener { 8 | public void OnFinished(); 9 | } -------------------------------------------------------------------------------- /app/src/main/java/com/why/project/spinnerviewpopdemo/views/spinner/listener/OnSpinnerConfirmClickListener.java: -------------------------------------------------------------------------------- 1 | package com.why.project.spinnerviewpopdemo.views.spinner.listener; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * Created by HaiyuKing 7 | * Used 多选对话框的确定按钮的点击事件监听 8 | */ 9 | 10 | public interface OnSpinnerConfirmClickListener { 11 | public void OnConfirmed(ArrayList selecteIndexList); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/why/project/spinnerviewpopdemo/views/spinner/listener/OnSpinnerItemClickListener.java: -------------------------------------------------------------------------------- 1 | package com.why.project.spinnerviewpopdemo.views.spinner.listener; 2 | 3 | 4 | /** 5 | * @Created HaiyuKing 6 | * @Used 下拉菜单列表项点击事件 7 | */ 8 | public interface OnSpinnerItemClickListener { 9 | public void OnFinished(int position); 10 | } -------------------------------------------------------------------------------- /app/src/main/java/com/why/project/spinnerviewpopdemo/views/spinner/util/DialogUtil.java: -------------------------------------------------------------------------------- 1 | package com.why.project.spinnerviewpopdemo.views.spinner.util; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | import android.content.DialogInterface; 6 | import android.view.View; 7 | import android.widget.ListView; 8 | import android.widget.TextView; 9 | 10 | import com.why.project.spinnerviewpopdemo.R; 11 | import com.why.project.spinnerviewpopdemo.bean.SpinnearBean; 12 | import com.why.project.spinnerviewpopdemo.views.spinner.adapter.MySpinnerPopListArrayAdapter; 13 | import com.why.project.spinnerviewpopdemo.views.spinner.adapter.MySpinnerPopMultListArrayAdapter; 14 | 15 | import java.util.ArrayList; 16 | 17 | public class DialogUtil { 18 | 19 | /*=============列表对话框=====================*/ 20 | private static Dialog dialog = null; 21 | private static View view; 22 | 23 | /*=============列表对话框:样式一:单选(无radio样式)=====================*/ 24 | /** 25 | *@param itemClickListener - 列表项的点击事件监听:执行调用该方式的父类的自定义监听事件 */ 26 | public static void showListDialog(Context context, ArrayList mArrayList, final MySpinnerPopListArrayAdapter.OnMyItemClickListener itemClickListener, final int selecteItem) { 27 | //引用进度列表对话框布局文件 28 | view = View.inflate(context, R.layout.spinnerview_pop_list_layout, null); 29 | 30 | //列表 31 | ListView mListView = (ListView) view.findViewById(R.id.list); 32 | MySpinnerPopListArrayAdapter mArrayAdapter = new MySpinnerPopListArrayAdapter(context, R.layout.spinnerview_pop_list_item, mArrayList,selecteItem); 33 | mListView.setAdapter(mArrayAdapter); 34 | mArrayAdapter.setOnMyItemClickListener(itemClickListener);//此处必须是自定义的adapter设置监听接口 35 | 36 | //设置选中的列表项的焦点 37 | mListView.setSelectionFromTop(selecteItem, 0); 38 | 39 | dialog = new Dialog(context, R.style.dialogutil_list_style); 40 | //设置为false,按对话框以外的地方不起作用 41 | dialog.setCanceledOnTouchOutside(true); 42 | //设置为false,按返回键不能退出 43 | dialog.setCancelable(true); 44 | dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { 45 | @Override 46 | public void onDismiss(DialogInterface dialog) { 47 | if(itemClickListener != null){ 48 | itemClickListener.OnMyItemClick(-1); 49 | } 50 | } 51 | }); 52 | dialog.setContentView(view); 53 | dialog.show(); 54 | } 55 | 56 | /*=============列表对话框:样式二:多选(radio样式)=====================*/ 57 | /** 58 | *@param itemClickListener - 列表项的点击事件监听:执行调用该方式的父类的自定义监听事件 */ 59 | public static void showListMultDialog(Context context, ArrayList mArrayList, final MySpinnerPopMultListArrayAdapter.OnMyMultItemClickListener itemClickListener) { 60 | //引用进度列表对话框布局文件 61 | view = View.inflate(context, R.layout.spinnerview_pop_list_layout_mult, null); 62 | 63 | //列表 64 | ListView mListView = (ListView) view.findViewById(R.id.list); 65 | final MySpinnerPopMultListArrayAdapter mArrayAdapter = new MySpinnerPopMultListArrayAdapter(context, R.layout.spinnerview_pop_list_item_mult, mArrayList); 66 | mListView.setAdapter(mArrayAdapter); 67 | mArrayAdapter.setOnMyItemClickListener(itemClickListener);//此处必须是自定义的adapter设置监听接口 68 | 69 | //确定 70 | TextView confirmTv = (TextView) view.findViewById(R.id.tv_confirm); 71 | confirmTv.setOnClickListener(new View.OnClickListener() { 72 | @Override 73 | public void onClick(View v) { 74 | if(itemClickListener != null){ 75 | //局部变量监听接口,用于获取多选的选中状态列表集合,然后用于确定文本的点击事件 76 | ArrayList selecteIndexList = new ArrayList(); 77 | selecteIndexList = mArrayAdapter.getSelecteIndex(); 78 | itemClickListener.OnMyMultItemClick(selecteIndexList);//选中状态集合 79 | } 80 | } 81 | }); 82 | //取消 83 | TextView cancelTv = (TextView) view.findViewById(R.id.tv_cancel); 84 | cancelTv.setOnClickListener(new View.OnClickListener() { 85 | @Override 86 | public void onClick(View v) { 87 | closeDialog();//关闭对话框,自动执行onDismiss中的方法 88 | } 89 | }); 90 | 91 | dialog = new Dialog(context, R.style.dialogutil_list_style); 92 | //设置为false,按对话框以外的地方不起作用 93 | dialog.setCanceledOnTouchOutside(true); 94 | //设置为false,按返回键不能退出 95 | dialog.setCancelable(true); 96 | dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { 97 | @Override 98 | public void onDismiss(DialogInterface dialog) { 99 | if(itemClickListener != null){ 100 | itemClickListener.OnMyMultItemClick(new ArrayList());//空的选中状态集合 101 | } 102 | } 103 | }); 104 | dialog.setContentView(view); 105 | dialog.show(); 106 | } 107 | 108 | /** 109 | * 关闭正在显示的对话框*/ 110 | public static void closeDialog() { 111 | if (dialog != null && dialog.isShowing()) { 112 | dialog.dismiss(); 113 | dialog = null; 114 | } 115 | } 116 | } -------------------------------------------------------------------------------- /app/src/main/java/com/why/project/spinnerviewpopdemo/views/spinner/util/PopWindowUtil.java: -------------------------------------------------------------------------------- 1 | package com.why.project.spinnerviewpopdemo.views.spinner.util; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.ColorDrawable; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup.LayoutParams; 8 | import android.widget.ListView; 9 | import android.widget.PopupWindow; 10 | import android.widget.PopupWindow.OnDismissListener; 11 | import com.why.project.spinnerviewpopdemo.R; 12 | import com.why.project.spinnerviewpopdemo.bean.SpinnearBean; 13 | import com.why.project.spinnerviewpopdemo.views.spinner.adapter.MySpinnerPopListArrayAdapter; 14 | 15 | import java.util.ArrayList; 16 | 17 | /** 18 | * @Created HaiyuKing 19 | * @Used PopWindow样式的下拉菜单 20 | */ 21 | public class PopWindowUtil { 22 | 23 | /**下拉菜单的弹出窗口*/ 24 | private static PopupWindow popupWindow = null; 25 | 26 | /**显示popupWindow弹出框*/ 27 | public static void showPopupWindows(Context context, final View spinnerview, ArrayList mArrayList, final MySpinnerPopListArrayAdapter.OnMyItemClickListener itemClickListener, int selecteItem){ 28 | 29 | if(popupWindow != null){ 30 | if(popupWindow.isShowing()){ 31 | popupWindow.dismiss(); 32 | popupWindow = null; 33 | } 34 | } 35 | //一个自定义的布局,作为显示的内容 36 | View popupWindowView = LayoutInflater.from(context).inflate(R.layout.spinnerview_pop_list_layout, null); 37 | 38 | /**在初始化contentView的时候,强制绘制contentView,并且马上初始化contentView的尺寸。 39 | * 另外一个点需要注意:popwindow_layout.xml的根Layout必须为LinearLayout;如果为RelativeLayout的话,会导致程序崩溃。*/ 40 | popupWindowView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); 41 | 42 | //用于获取单个列表项的高度 43 | View listitemView = LayoutInflater.from(context).inflate(R.layout.spinnerview_pop_list_item, null); 44 | listitemView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); 45 | 46 | //列表 47 | ListView mListView = (ListView) popupWindowView.findViewById(R.id.list); 48 | MySpinnerPopListArrayAdapter mArrayAdapter = new MySpinnerPopListArrayAdapter(context, R.layout.spinnerview_pop_list_item, mArrayList,selecteItem); 49 | mListView.setAdapter(mArrayAdapter); 50 | mArrayAdapter.setOnMyItemClickListener(itemClickListener);//此处必须是自定义的adapter设置监听接口 51 | 52 | //设置选中的列表项的焦点 53 | mListView.setSelectionFromTop(selecteItem, 0); 54 | 55 | //实例化PopupWindow【宽度为屏幕宽度,高度为自身高度】 56 | //popupWindow = new PopupWindow(popupWindowView, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 57 | //【宽度为依赖控件的宽度,高度为4个列表项的高度】【添加了判断,如果小于4个,则wrap_content】 58 | if(mArrayList.size() <= 8){ 59 | popupWindow = new PopupWindow(popupWindowView, spinnerview.getMeasuredWidth(), LayoutParams.WRAP_CONTENT); 60 | }else{ 61 | popupWindow = new PopupWindow(popupWindowView, spinnerview.getMeasuredWidth(), listitemView.getMeasuredHeight() * 8); 62 | } 63 | 64 | popupWindow.setTouchable(true);//设置可以触摸 65 | popupWindow.setFocusable(true);//代表可以允许获取焦点的,如果有输入框的话,可以聚焦 66 | 67 | //监听popWindow的隐藏时执行的操作--这个不错 68 | popupWindow.setOnDismissListener(new OnDismissListener() { 69 | @Override 70 | public void onDismiss() { 71 | //执行还原原始状态的操作,比如选中状态颜色高亮显示[去除],不能使用notifyDataSetInvalidated(),否则会出现popwindow显示错位的情况 72 | if(itemClickListener != null){ 73 | itemClickListener.OnMyItemClick(-1); 74 | } 75 | } 76 | }); 77 | 78 | //下面两个参数是实现点击点击外面隐藏popupwindow的 79 | //这里设置显示PopuWindow之后在外面点击是否有效。如果为false的话,那么点击PopuWindow外面并不会关闭PopuWindow。当然这里很明显只能在Touchable下才能使用。不设置此项则下面的捕获window外touch事件就无法触发。 80 | popupWindow.setOutsideTouchable(true); 81 | 82 | // 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框 83 | // 我觉得这里是API的一个bug 84 | //方式一 85 | ColorDrawable dw = new ColorDrawable(0x00000000); 86 | popupWindow.setBackgroundDrawable(dw); 87 | 88 | //int xPos = - popupWindow.getWidth() / 2 + view.getWidth() / 2;//X轴的偏移值:xoff表示x轴的偏移,正值表示向右,负值表示向左; 89 | int xPos = 0;//X轴的偏移值:xoff表示x轴的偏移,正值表示向左,负值表示向右; 90 | int yPos = 0;//Y轴的偏移值相对某个控件的位置,有偏移;yoff表示相对y轴的偏移,正值是向下,负值是向上; 91 | 92 | //=======展现在控件的下方 93 | //相对于当前view进行位置设置 94 | popupWindow.showAsDropDown(spinnerview, xPos, yPos); 95 | } 96 | 97 | /**关闭列表弹出框*/ 98 | public static void closePopupWindows(){ 99 | if(popupWindow != null){ 100 | if(popupWindow.isShowing()){ 101 | popupWindow.dismiss(); 102 | popupWindow = null; 103 | } 104 | } 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/spinnerview_pop_icon_ck_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/app/src/main/res/drawable-xxhdpi/spinnerview_pop_icon_ck_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/spinnerview_pop_icon_ck_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/app/src/main/res/drawable-xxhdpi/spinnerview_pop_icon_ck_selected.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/spinnerview_pop_icon_shang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/app/src/main/res/drawable-xxhdpi/spinnerview_pop_icon_shang.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/spinnerview_pop_icon_xia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/app/src/main/res/drawable-xxhdpi/spinnerview_pop_icon_xia.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/spinnerview_pop_list_line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/app/src/main/res/drawable-xxhdpi/spinnerview_pop_list_line.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/spinnerview_pop_box_bg_drawable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 9 | 10 | 11 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/spinnerview_pop_list_bg_drawable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 9 | 10 | 11 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/spinnerview_pop_listitem_bg_drawable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 23 | 24 | 25 | 32 | 33 | 34 | 41 | 42 | 43 | 50 | 51 | 52 | 59 | 60 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /app/src/main/res/layout/spinnerview_pop_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/spinnerview_pop_list_item_mult.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/spinnerview_pop_list_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 14 | 16 | 17 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/spinnerview_pop_list_layout_mult.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 14 | 16 | 17 | 27 | 28 | 29 | 30 | 35 | 36 | 37 | 42 | 43 | 44 | 52 | 53 | 54 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /app/src/main/res/layout/spinnerview_pop_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | 8 | 9 | #0365C5 10 | 11 | #191919 12 | 13 | #ffffff 14 | 15 | #C5C5C5 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 7 | 8 | 18sp 9 | 10 | 18sp 11 | 12 | 10dp 13 | 14 | 42dp 15 | 16 | 20dp 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SpinnerViewPopDemo 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/test/java/com/why/project/spinnerviewpopdemo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.why.project.spinnerviewpopdemo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.2' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /安装包/app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiyuKing/SpinnerViewPopDemo/a08beff892fee34fd5e68672929fd0492186e21b/安装包/app-debug.apk --------------------------------------------------------------------------------