Да, это возможно и действительно очень просто. Когда вы используете свой GridView, предоставьте ему адаптер. В методе getview
адаптера вы можете создать любое представление и вернуть его. Например, вы можете раздуть представление из XML - и этот xml может содержать LinearLayout
. Кроме того, вы можете создать линейный макет на лету в этом методе и добавить к нему другие компоненты.
Посмотрите эту статью в Google: http://developer.android.com/resources/tutorials/views/hello-gridview.html
Обновление: маленький пример
В вашем res/layout/item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="0dip"
android:paddingBottom="0dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/TxtName"
android:scrollHorizontally="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:layout_weight="0.2"
android:padding="2dp"/>
<TextView android:id="@+id/TxtPackage"
android:scrollHorizontally="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:textColor="@android:color/black"
android:padding="2dp"/>
</LinearLayout>
Тогда в вашем адаптере:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//get the item corresponding to your position
LinearLayout row = (LinearLayout) (convertView == null
? LayoutInflater.from(context).inflate(R.layout.item, parent, false)
: convertView);
((TextView)row.findViewById(R.id.TxtName)).setText("first text");
((TextView)row.findViewById(R.id.TxtPackage)).setText("second text");
return row;
}