Android 第三方开源下拉框:NiceSpinner
Android原生的下拉框Spinner基本上可以满足Android开发对于下拉选项的设计需求,但现在越来越流行的下拉框不满足于Android原生提供的下拉框Spinner所提供的设计样式,而改用自定制或者第三方设计的下拉框Spinner。
NiceSpinner是一个第三方开源的下拉框Spinner,其在github上的项目主页是:https://github.com/arcadefire/nice-spinner
NiceSpinner原设计效果如动图所示:
但是通常开发者对于可能还需要对于下拉框中出现的文字和样式进行二次开发,比如如果希望NiceSpinner的选中文本颜色或者下拉弹出框中的文字有些变化,则需要重新二次定制NiceSpinner code项目中的NiceSpinnerBaseAdapter, NiceSpinnerBaseAdapter中的getView返回的view表现形式即为下拉框中的结果:
//这个方法将返回下拉列表的形制,可以在这里修改和二次定制开发。
//zhang phil 注解
@Override
@SuppressWarnings("unchecked")
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView; if (convertView == null) {
convertView = View.inflate(mContext, R.layout.spinner_list_item, null);
textView = (TextView) convertView.findViewById(R.id.tv_tinted_spinner); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
textView.setBackground(ContextCompat.getDrawable(mContext, mBackgroundSelector));
} convertView.setTag(new ViewHolder(textView));
} else {
textView = ((ViewHolder) convertView.getTag()).textView;
} textView.setText(getItem(position).toString());
textView.setTextColor(mTextColor); //这里是被zhang phil修改的,用于改变下拉列表的文字颜色。
textView.setTextColor(Color.RED); return convertView;
}
修改后,写一个小demo演示,测试的MainActivity.Java:
package zhangphil.demo; import java.util.Arrays;
import java.util.LinkedList;
import org.angmarch.views.NiceSpinner;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); NiceSpinner niceSpinner = (NiceSpinner) findViewById(R.id.nice_spinner);
niceSpinner.setTextColor(Color.GREEN); LinkedList<String> data=new LinkedList<>(Arrays.asList("Zhang", "Phil", "@", "CSDN"));
niceSpinner.attachDataSource(data);
}
}
布局文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="zhangphil.demo.MainActivity" > <org.angmarch.views.NiceSpinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:id="@+id/nice_spinner" /> </RelativeLayout>
代码运行结果:
我把NiceSpinner的代码库(library和实例demo)全部作为一个文件目录push到github上面,项目主页是:https://github.com/zhangphil/zhangphil-nice-spinner
Android 第三方开源下拉框:NiceSpinner的更多相关文章
- Android第三方开源下拉框:NiceSpinner
Android第三方开源下拉框:NiceSpinner Android原生的下拉框Spinner基本上可以满足Android开发对于下拉选项的设计需求,但现在越来越流行的下拉框不满足于Andro ...
- 030 Android 第三方开源下拉框:NiceSpinner的使用+自定义Button样式+shape绘制控件背景图+图片选择器(selector)
1.NiceSpinner下拉框控件介绍 Android原生的下拉框Spinner基本上可以满足Android开发对于下拉选项的设计需求,但现在越来越流行的下拉框不满足于Android原生提供的下拉框 ...
- android 开发-spinner下拉框控件的实现
Android提供实现下拉框功能的非常实用的控件Spinner. spinner控件需要向xml资源文件中添加spinner标签,如下: <Spinner android:id="@+ ...
- Android自定义spinner下拉框实现的实现
一:前言 本人参考博客:http://blog.csdn.net/jdsjlzx/article/details/41316417 最近在弄一个下拉框,发现Android自带的很难实现我的功能,于是去 ...
- Android 自定义spinner下拉框实现
一:前言本人参考博客:http://blog.csdn.net/jdsjlzx/article/details/41316417 最近在弄一个下拉框,发现Android自带的很难实现我的功能,于是去网 ...
- Android 自定义spinner下拉框实现的实现
请支持原创:http://blog.csdn.NET/geniuseoe2012/article/details/8723702 说到Android下拉框spineer,框架中虽有现成的控件,但实际效 ...
- android中自定义下拉框(转)
android自带的下拉框好用不?我觉得有时候好用,有时候难有,项目规定这样的效果,自带的控件实现不了,那么只有我们自己来老老实实滴写一个新的了,其实最基本的下拉框就像一些资料填写时,点击的时候出现在 ...
- android+myeclipse+mysql下拉框数据绑定
原创作品,允许转载,转载时请务必声明作者信息和本声明.http://www.cnblogs.com/zhu520/p/8027036.html 本人小白,那个大神看到有问题可指出,谢谢.... 一:我 ...
- android下拉框
XML: <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:androi ...
随机推荐
- sublime注释插件与javascript注释规范
前言 代码中注释是不可少的,即使是自己写的代码,过了一段时间之后再重看,如果没有注释记录的话,可能会想不到当初是这样实现的,尤其是在业务逻辑比较复杂的项目,注释变得尤为重要.怎么优雅的写有用的注释呢? ...
- 栈式自动编码器(Stacked AutoEncoder)
起源:自动编码器 单自动编码器,充其量也就是个强化补丁版PCA,只用一次好不过瘾. 于是Bengio等人在2007年的 Greedy Layer-Wise Training of Deep Netw ...
- oracle中利用trigger,sequence自动生成ID
http://zhanghong.iteye.com/blog/865937 1. 首先创建数据库表 SQL> create table customer( 2 id number(8) no ...
- Oracle 时间,日期 类型函数及参数详解
ORACLE字符数字日期之间转化 Java代码 24 小时的形式显示出来要用 HH24 select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss' ...
- 【JAVA】JMX简单使用方法
[BEAN] 配置 <!-- JMX 对应的接口服务--> <bean id="emailInterfaceServer" class="com.s ...
- Android控件属性大全(转)
http://blog.csdn.net/pku_android/article/details/7365685 LinearLayout 线性布局 子元素任意: Tab ...
- springboot 添加job定时任务
@SpringBootApplication@ComponentScan("com.xx")@EnableScheduling //定时任务扫描 此处用该注解,容器启动自动扫描pu ...
- 在springmvc中,获取Connection接口
ServletContext context = request.getSession().getServletContext();WebApplicationContext wac = WebApp ...
- 类库,委托,is和as运算符,泛型集合
类库:其实就是一堆类文件,只不过用户看不到这些类的源代码,保密性好. 优点:保密性好缺点:如果这个方法不好用,使用者无法自己去更改它. 类文件是.cs 类库是.dll 新建项目为类库,在debu ...
- AspCms标签手册
网站通用标签 基本标签 {aspcms:sitepath} 网站终极目录(可放在二级目录,其它语言则在三级目录) {aspcms:languagepath} 语言目录 {aspcms:siteurl} ...