Tuesday, January 31, 2012

gridview take2 issues


@Override
public View getView(int position, View convertView, ViewGroup parent) {
        TextView textView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
            textView = new TextView(mContext);
//            textView.setLayoutParams(new GridView.LayoutParams(40, 40));
            textView.setPadding(1, 8, 1, 8);
        } else {
            textView = (TextView) convertView;
        }
        textView.setText(mGridViewArrayStrings[position]);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP,7.0f);
        //TypedValue.COMPLEX_UNIT_PX : Pixels
        //TypedValue.COMPLEX_UNIT_SP : Scaled Pixels
        //TypedValue.COMPLEX_UNIT_DIP : Device Independent Pixels
        return textView;
}

================

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gridview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:numColumns="7"
    android:stretchMode="columnWidth"
    android:gravity="center"
android:soundEffectsEnabled="true"/>

================


No comments:

Post a Comment