@Override public View getView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; View view; if (convertView == null) { view = mInflater.inflate(R.layout.dialer_preferences, parent, false); holder = new HeaderViewHolder(); holder.title = (TextView) view.findViewById(R.id.title); holder.summary = (TextView) view.findViewById(R.id.summary); view.setTag(holder); } else { view = convertView; holder = (HeaderViewHolder) view.getTag(); } // All view fields must be updated every time, because the view may be recycled Header header = getItem(position); holder.title.setText(header.getTitle(getContext().getResources())); CharSequence summary = header.getSummary(getContext().getResources()); if (!TextUtils.isEmpty(summary)) { holder.summary.setVisibility(View.VISIBLE); holder.summary.setText(summary); } else { holder.summary.setVisibility(View.GONE); } return view; }
protected Object onCreateAppOpsHeader(Context context, int addAfterHeaderId) { final Header appOpsHeader = new Header(); appOpsHeader.title = getAppOpsTitle(); appOpsHeader.id = R.id.app_ops_settings; appOpsHeader.iconRes = getAppOpsHeaderIcon(); appOpsHeader.intent = Util.createAppOpsIntent(null); return appOpsHeader; }
@Override public void onBuildHeaders(List<Header> target) { final Header generalSettingsHeader = new Header(); generalSettingsHeader.titleRes = R.string.general_settings_label; generalSettingsHeader.summaryRes = R.string.general_settings_description; generalSettingsHeader.fragment = GeneralSettingsFragment.class.getName(); target.add(generalSettingsHeader); // Only add the call settings header if the current user is the primary/owner user. if (isPrimaryUser()) { final Header callSettingHeader = new Header(); callSettingHeader.titleRes = R.string.call_settings_label; callSettingHeader.summaryRes = R.string.call_settings_description; callSettingHeader.intent = DialtactsActivity.getCallSettingsIntent(); target.add(callSettingHeader); } }