FileDocCategorySizeDatePackage
HistoryAdapter.javaAPI DocAndroid 1.5 API2460Wed May 06 22:42:42 BST 2009com.android.calculator2

HistoryAdapter

public class HistoryAdapter extends android.widget.BaseAdapter

Fields Summary
private Vector
mEntries
private android.view.LayoutInflater
mInflater
private Logic
mEval
Constructors Summary
HistoryAdapter(android.content.Context context, History history, Logic evaluator)

        mEntries = history.mEntries;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mEval = evaluator;
    
Methods Summary
public intgetCount()

        return mEntries.size() - 1;
    
public java.lang.ObjectgetItem(int position)

        return mEntries.elementAt(position);
    
public longgetItemId(int position)

        return position;
    
public android.view.ViewgetView(int position, android.view.View convertView, android.view.ViewGroup parent)

        View view;
        if (convertView == null) {
            view = mInflater.inflate(R.layout.history_item, parent, false);
        } else {
            view = convertView;
        }

        TextView expr   = (TextView) view.findViewById(R.id.historyExpr);
        TextView result = (TextView) view.findViewById(R.id.historyResult);

        HistoryEntry entry = mEntries.elementAt(position);
        String base = entry.getBase();
        expr.setText(entry.getBase());

        try {
            String res = mEval.evaluate(base);
            result.setText("= " + res);
        } catch (SyntaxException e) {
            result.setText("");
        }

        return view;
    
public booleanhasStableIds()

        return true;