
package com.uwetrottmann.shopr.ui;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.uwetrottmann.shopr.R;
import com.uwetrottmann.shopr.model.Item;

import java.text.NumberFormat;
import java.util.Locale;

public class CritiqueActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_critique);
        // Show the Up button in the action bar.
        setupActionBar();
    }

    /**
     * Set up the {@link android.app.ActionBar}.
     */
    private void setupActionBar() {

        getActionBar().setDisplayHomeAsUpEnabled(true);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.critique, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                // This ID represents the Home or Up button. In the case of this
                // activity, the Up button is shown. Use NavUtils to allow users
                // to navigate up one level in the application structure. For
                // more details, see the Navigation pattern on Android Design:
                //
                // http://developer.android.com/design/patterns/navigation.html#up-vs-back
                //
                NavUtils.navigateUpFromSameTask(this);
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public class ItemFeatureAdapter extends BaseAdapter {

        private static final int LAYOUT = R.layout.feature_row;
        private Item mItem;
        private Context mContext;
        private LayoutInflater mLayoutInflater;

        public ItemFeatureAdapter(Context context, Item item) {
            mContext = context;
            mItem = item;
            mLayoutInflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }

        @Override
        public int getCount() {
            return 5;
        }

        @Override
        public Object getItem(int position) {
            return mItem;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder;

            if (convertView == null) {
                convertView = mLayoutInflater.inflate(LAYOUT, parent, false);

                holder = new ViewHolder();
                holder.title = (CheckBox) convertView.findViewById(R.id.checkBoxFeatureTitle);
                holder.value = (TextView) convertView.findViewById(R.id.textViewFeatureValue);

                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }

            Item item = (Item) getItem(position);
            holder.title.setText("Price");
            holder.value.setText(NumberFormat.getCurrencyInstance(Locale.GERMANY).format(
                    item.price().doubleValue()));

            return convertView;
        }

    }

    static class ViewHolder {
        CheckBox title;
        TextView value;
    }

}

@@ -373,16 +373,48 @@
 eckBox;%0A
+import android.widget.ListView;%0A
 import a
@@ -514,16 +514,45 @@
 .Item;%0A%0A
+import java.math.BigDecimal;%0A
 import j
@@ -658,243 +658,1068 @@
     
-@Override%0A    protected void onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);%0A        setContentView(R.layout.activity_critique);%0A        // Show the Up button in the action bar.%0A        setupActionBar(
+private TextView mQuestion;%0A    private ListView mListView;%0A    private Item mItem;%0A    private ItemFeatureAdapter mAdapter;%0A    private boolean mIsPositiveCritique;%0A%0A    @Override%0A    protected void onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);%0A        setContentView(R.layout.activity_critique);%0A%0A        mItem = new Item().id(123).name(%22Some Item%22).picture(%22%22)%0A                .price(new BigDecimal(25.99));%0A        mIsPositiveCritique = true;%0A%0A        // Show the Up button in the action bar.%0A        setupActionBar();%0A        setupViews();%0A        setupAdapter();%0A    %7D%0A%0A    private void setupAdapter() %7B%0A        mAdapter = new ItemFeatureAdapter(this, mItem);%0A        mListView.setAdapter(mAdapter);%0A    %7D%0A%0A    private void setupViews() %7B%0A        mQuestion = (TextView) findViewById(R.id.textViewCritiqueQuestion);%0A        mQuestion.setText(getString(mIsPositiveCritique ? R.string.detail_like%0A                : R.string.detail_dislike, mItem.name()));%0A        mListView = (ListView) findViewById(R.id.listViewCritique
 );%0A 

Load sample data in CritiqueActivity.