新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Android第三方開源下拉框NiceSpinner使用詳解-創(chuàng)新互聯(lián)
android原生的下拉框Spinner基本上可以滿足Android開發(fā)對于下拉選項(xiàng)的設(shè)計(jì)需求,但現(xiàn)在越來越流行的下拉框不滿足于Android原生提供的下拉框Spinner所提供的設(shè)計(jì)樣式,而改用自定制或者第三方設(shè)計(jì)的下拉框Spinner。
NiceSpinner是一個(gè)第三方開源的下拉框Spinner,其在github上的項(xiàng)目主頁是:https://github.com/arcadefire/nice-spinner
NiceSpinner原設(shè)計(jì)效果如動(dòng)圖所示:
但是通常開發(fā)者對于可能還需要對于下拉框中出現(xiàn)的文字和樣式進(jìn)行二次開發(fā),比如如果希望NiceSpinner的選中文本顏色或者下拉彈出框中的文字有些變化,則需要重新二次定制NiceSpinner code項(xiàng)目中的NiceSpinnerBaseAdapter, NiceSpinnerBaseAdapter中的getView返回的view表現(xiàn)形式即為下拉框中的結(jié)果:
//這個(gè)方法將返回下拉列表的形制,可以在這里修改和二次定制開發(fā)。 //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; }
分享名稱:Android第三方開源下拉框NiceSpinner使用詳解-創(chuàng)新互聯(lián)
轉(zhuǎn)載注明:http://www.ef60e0e.cn/article/dsggdj.html