本文主要是介绍继承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类的实例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!