@Override public void onItemClick( final AdapterView<?> adapter, final View view, final int position, final long id) { final DocsEntry item = docsEntries.get(position); switch (item.getType()) { case DocsEntry.COLLECTION: Intent intent = new Intent(QuizBrowserActivity.this, QuizBrowserActivity.class); intent.putExtra(QuizBrowserActivity.EXTRA_COLLECTION_ID, item.getId()); intent.putExtra(QuizBrowserActivity.EXTRA_TITLE, item.getTitle()); startActivity(intent); break; case DocsEntry.QUIZ: Intent intent2 = new Intent(this, QuizInfoActivity.class); intent2.putExtra(QuizInfoActivity.EXTRA_DOC_ID, item.getId()); startActivity(intent2); break; } }
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = vi.inflate(R.layout.list_item_icon, parent, false); } DocsEntry item = items.get(position); TextView text = (TextView) view.findViewById(R.id.title); text.setText(item.getTitle()); ImageView icon = (ImageView) view.findViewById(R.id.icon); switch (item.getType()) { case DocsEntry.COLLECTION: icon.setImageResource(R.drawable.folder); break; case DocsEntry.QUIZ: icon.setImageResource(R.drawable.quiz); break; } return view; }