編輯:關於Android編程
private boolean isAllChecked = false;
if (isAllChecked) { selectAllBtn.setBackgroundResource(R.drawable.select_all_not); invertSelection(); } else { selectAllBtn.setBackgroundResource(R.drawable.select_all); selectAllContacts(); }
public void selectAllContacts() { for (int i = 0; i < contactList.size(); i++) { Contact contact = contactList.get(i); map_NumberSelected.put(contact, true); } isAllChecked = true; refreshList(); }
public void invertSelection() { for (int i = 0; i < contactList.size(); i++) { Contact contact = contactList.get(i); map_NumberSelected.put(contact, false); } isAllChecked = false; refreshList(); }
package com.suntek.mobilemeeting.adapter; import java.util.ArrayList; import java.util.HashMap; import android.content.Context; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.CheckBox; import android.widget.TextView; import com.suntek.mobilemeeting.R; import com.suntek.mobilemeeting.model.Contact; /** * 本地聯系人適配器 * * @author wwj * */ public class LocalContactAdapter extends BaseAdapter { private HashMaplmap = new HashMap (); private ArrayList contactList; private Context context; private HashMap map_NumberSelected = null; private String kind; public class ViewHolder { public TextView contactName; public TextView contactMobile; public TextView contactEmail; public CheckBox checkBox; } public LocalContactAdapter(Context context, ArrayList contactList, String kind) { this.contactList = contactList; this.context = context; map_NumberSelected = new HashMap (); this.kind = kind; } @Override public int getCount() { return contactList.size(); } @Override public Object getItem(int position) { return contactList.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.local_contact_list_item, null); holder.contactName = (TextView) convertView .findViewById(R.id.name_tv); holder.contactMobile = (TextView) convertView .findViewById(R.id.number_tv); holder.contactEmail = (TextView) convertView .findViewById(R.id.email_tv); holder.checkBox = (CheckBox) convertView .findViewById(R.id.local_contact_checkbox); // lmap.put(position, convertView); convertView.setTag(holder); } else { // convertView = lmap.get(position); holder = (ViewHolder) convertView.getTag(); } Contact contact = contactList.get(position); if (contact.getName() == "" || contact.getName() == null) { String name = "未知"; holder.contactName.setText(name); } else { holder.contactName.setText(contact.getName()); } if (kind != null && kind.equals("email")) { if (!TextUtils.isEmpty(contact.getEmail())) { holder.contactEmail.setText(contact.getEmail()); holder.contactMobile.setVisibility(View.GONE); } } else if (!TextUtils.isEmpty(contact.getNumber())) { holder.contactMobile.setText(contact.getNumber()); holder.contactEmail.setVisibility(View.GONE); } else { holder.contactMobile.setVisibility(View.GONE); holder.contactEmail.setVisibility(View.GONE); } // 顯示是否選中狀態 holder.checkBox.setChecked(map_NumberSelected.get(contact)); return convertView; } public void setContactList(ArrayList contactList) { this.contactList = contactList; } public void setMap_NumberSelected( HashMap map_NumberSelected) { this.map_NumberSelected = map_NumberSelected; } }
android5.0以後出現了Toolbar,今天折騰了一下,在此做個記錄方便以後查看,同時也給有需要的朋友們參考!!!!!很慚愧只做了一點微小的工作。下面將完成兩個方面
上一篇文章中我們介紹了android社區中比較火的熱修復功能,並介紹了目前的幾個比較流行的熱修復框架,以及各自的優缺點,同時也介紹了一下自身項目中對熱修復功能的實踐。目前
1 查看手機CPU信息 cmd——adb shell——cd /proc------cat cpuinfo 2 獲取cpu的是arm指令集,armv7指令集、還是ne
一、ActionBar概述ActionBar是androiD3.0以後新增的組件,主要用於標示應用程序以及用戶所處的位置並提供相關操作以及全局的導航功能。下