Code example for TextView

Methods: setHeight, setBackgroundColor, setId, setLayoutParams

0
     * @param desiredHeight The height the view should be to respect the desired item 
     *   to screen height ratio. 
     * @return a view for the grid. 
     */ 
    protected View createView(int position, ViewGroup parent, int desiredHeight) {
        TextView result = new TextView(parent.getContext());
        result.setHeight(desiredHeight);
        result.setText(getValueAtPosition(position));
        final ViewGroup.LayoutParams lp = new AbsListView.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        result.setLayoutParams(lp);
        result.setId(position);
        result.setBackgroundColor(0x55ffffff);
        return result;
    } 
 
 
 
    private class MyAdapter extends BaseAdapter {
        public int getCount() {