继承ArrayAdapter类的实例

2024-08-23 11:58
文章标签 实例 继承 arrayadapter

本文主要是介绍继承ArrayAdapter类的实例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

private class SelectAccountListAdapter extends ArrayAdapter<String>{private Context mContext;private int mResId;private int mDialogId;private final float OPACITY=0.54f;//opacity不透明的private List<SubscriptionInfo>mSubInfoList;public SelectAccountListAdapter(List<SubscriptionInfo>subInfoList,Context context,int resource,string[] arr,int dialogId){super(context,resource,arr);mContext=context;mResId=resource;mDialogId=dialogId;mSubInfoList=subInfoList;}@Overridepublic View getView(int position, View convertView, ViewGroup parent) {LayoutInflater inflater=(LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);View rowView;final ViewHolder holder;if(convertView==null){rowView=inflater.inflate(mResId, null);holder=new ViewHolder();holder.title=(TextView)rowView.findViewById(R.id.title);holder.summary=(TextView)rowView.findViewById(R.id.summary);holder.icon=(ImageView)rowView.findViewById(R.id.icon);rowView.setTag(holder);}else{rowView=convertView;holder=(ViewHolder)rowView.getTag();}final SubscriptionInfo sir=mSubInfoList.get(position);if(sir==null){holder.title.setText(getItem(position));hodler.summary.setText("");if(mDialogId==CALL_PICK){setPhoneAccountIcon(holder,position);}else{holder.icon.setImageDrawable(getResource().getDrawable(R.drawable.ic_live_help));}mSimManagementExt.setSmsAutoItemIcon(holder.icon,mDialogId,postion);mSimManagementExt.setCurrNetworkIcon(holder.icon,mDialogId,position);holder.icon.setAlpha(OPACITY);}else{holder.title.setText(sir.getDisplayName());holder.summary.setText(sir.getNumber());holder.icon.setImageDrawable(sir.createIconBitmap(mContext));holder.icon.setAlpha(1.0f);}return rowView;}private class ViewHolder{TextView title;TextView summary;ImageView icon;}private void setPhoneAccountIcon(ViewHolder holder,int location){String askFirst=getResources().getString(R.string.sim_calls_ask_first_prefs_title);String lableString=getItem(location);final TelecomManager telecomManager=TelecomManager.from(mContext);List<PhoneAccountHandle> phoneAccountHandles=telecomManager.getCallCapablePhoneAccounts();if(!askFirst.equals(lableString)){if(phoneAccountHandles.size()>1){location=location-1;}PhoneAccount phoneAccount=null;if(location>=0 && location<phoneAccountHandles.size()){phoneAccount=telecomManager.getPhoneAccount(phoneAccountHandles.get(location));}if(phoneAccount!=null){holder.icon.setImageDrawable(phoneAccount.getIcon().loadDrawable(mContext));}}else{holder.icon.setImageDrawable(getResources().getDrawable(R.drawable.ic_live_help));}}}

这篇关于继承ArrayAdapter类的实例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1099319

相关文章

Python开发文字版随机事件游戏的项目实例

《Python开发文字版随机事件游戏的项目实例》随机事件游戏是一种通过生成不可预测的事件来增强游戏体验的类型,在这篇博文中,我们将使用Python开发一款文字版随机事件游戏,通过这个项目,读者不仅能够... 目录项目概述2.1 游戏概念2.2 游戏特色2.3 目标玩家群体技术选择与环境准备3.1 开发环境3

Vue3组件中getCurrentInstance()获取App实例,但是返回null的解决方案

《Vue3组件中getCurrentInstance()获取App实例,但是返回null的解决方案》:本文主要介绍Vue3组件中getCurrentInstance()获取App实例,但是返回nu... 目录vue3组件中getCurrentInstajavascriptnce()获取App实例,但是返回n

SQL表间关联查询实例详解

《SQL表间关联查询实例详解》本文主要讲解SQL语句中常用的表间关联查询方式,包括:左连接(leftjoin)、右连接(rightjoin)、全连接(fulljoin)、内连接(innerjoin)、... 目录简介样例准备左外连接右外连接全外连接内连接交叉连接自然连接简介本文主要讲解SQL语句中常用的表

C# WinForms存储过程操作数据库的实例讲解

《C#WinForms存储过程操作数据库的实例讲解》:本文主要介绍C#WinForms存储过程操作数据库的实例,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、存储过程基础二、C# 调用流程1. 数据库连接配置2. 执行存储过程(增删改)3. 查询数据三、事务处

springboot security验证码的登录实例

《springbootsecurity验证码的登录实例》:本文主要介绍springbootsecurity验证码的登录实例,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录前言代码示例引入依赖定义验证码生成器定义获取验证码及认证接口测试获取验证码登录总结前言在spring

tomcat多实例部署的项目实践

《tomcat多实例部署的项目实践》Tomcat多实例是指在一台设备上运行多个Tomcat服务,这些Tomcat相互独立,本文主要介绍了tomcat多实例部署的项目实践,具有一定的参考价值,感兴趣的可... 目录1.创建项目目录,测试文China编程件2js.创建实例的安装目录3.准备实例的配置文件4.编辑实例的

python+opencv处理颜色之将目标颜色转换实例代码

《python+opencv处理颜色之将目标颜色转换实例代码》OpenCV是一个的跨平台计算机视觉库,可以运行在Linux、Windows和MacOS操作系统上,:本文主要介绍python+ope... 目录下面是代码+ 效果 + 解释转HSV: 关于颜色总是要转HSV的掩膜再标注总结 目标:将红色的部分滤

Spring 中使用反射创建 Bean 实例的几种方式

《Spring中使用反射创建Bean实例的几种方式》文章介绍了在Spring框架中如何使用反射来创建Bean实例,包括使用Class.newInstance()、Constructor.newI... 目录1. 使用 Class.newInstance() (仅限无参构造函数):2. 使用 Construc

MyBatis-Plus中Service接口的lambdaUpdate用法及实例分析

《MyBatis-Plus中Service接口的lambdaUpdate用法及实例分析》本文将详细讲解MyBatis-Plus中的lambdaUpdate用法,并提供丰富的案例来帮助读者更好地理解和应... 目录深入探索MyBATis-Plus中Service接口的lambdaUpdate用法及示例案例背景

MyBatis-Plus中静态工具Db的多种用法及实例分析

《MyBatis-Plus中静态工具Db的多种用法及实例分析》本文将详细讲解MyBatis-Plus中静态工具Db的各种用法,并结合具体案例进行演示和说明,具有很好的参考价值,希望对大家有所帮助,如有... 目录MyBATis-Plus中静态工具Db的多种用法及实例案例背景使用静态工具Db进行数据库操作插入