private void initItems() { Resources res = getResources(); titels = res.getStringArray(R.array.privacyspace_items_title); subTitles = res.getStringArray(R.array.privacyspace_items_subtitle); int[] intIcons = { R.drawable.ic_security_pricacy_contact_normal, R.drawable.ic_security_pricacy_photo_normal, R.drawable.ic_security_pricacy_paper_normal, R.drawable.ic_security_pricacy_key_normal }; // get four icon for (int i = 0; i < ITEM_NUMBER; i++) { drawableIcons[i] = res.getDrawable(intIcons[i]); Log.i(TAG, drawableIcons[i] + ""); Log.i(TAG, titels[i] + ""); Log.i(TAG, subTitles[i] + ""); } // get mList for (int i = 0; i < ITEM_NUMBER; i++) { PrivacySpaceListItem item = new PrivacySpaceListItem(); item.setDrawable(drawableIcons[i]); item.setTitle(titels[i]); item.setSubtitle(subTitles[i]); mList.add(item); } mAdapter = new PrivacySpaceAdapter(mContext, mList); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(this); }
@Override public View getView(int position, View convertView, ViewGroup parent) { PrivacySpaceListItem item = adapterList.get(position); View v = View.inflate(adapterContext, R.layout.privacyspace_main_listview_item, null); icon = (ImageView) v.findViewById(R.id.iv_privacyspace_item); tvTitle = (TextView) v.findViewById(R.id.tv_privacyspace_item_title); tvSubTitle = (TextView) v.findViewById(R.id.tv_privacyspace_item_subtitle); icon.setImageDrawable(item.getDrawable()); tvTitle.setText(item.getTitle()); tvSubTitle.setText(item.getSubtitle()); return v; }