So füllen Sie mit customAdapter die Höhe der Rasteransicht
Ich arbeite an der Sudoku-App. Das Layout ist 9x9 GridView. Jede GridView enthält 9 Textviews von customAdapter. Ich möchte die 9 TextViews so gestalten, dass sie die Höhe jedes GridView ausfüllen. Wie?
Das habe ich jetzt
Hier ist myGridAdapter:
public class myGridAdapter extends BaseAdapter {
private Context context;
private String[] mobileValues;
public myGridAdapter(MainActivity mainActivity, String[] arrayEmpty) {
this.context = mainActivity;
this.mobileValues = arrayEmpty;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
if (convertView == null) {
gridView = new View(context);
// get layout from text_item.xml
gridView = inflater.inflate(R.layout.text_item, null);
// set value into textview
TextView textView = (TextView) gridView
.findViewById(R.id.grid_item_label);
textView.setText(mobileValues[position]);
} else {
gridView = (View) convertView;
}
return gridView;
}
.....
}
Dies ist die XML für jedes Textelement
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/grid_item_label"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@drawable/cell_shape"
android:text="@string/_1"
tools:ignore="InefficientWeight"
android:textSize="12sp" >
</TextView>
</LinearLayout>
Dies ist die Form für jede Textansicht
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<solid android:color="#FFFFFF"/>
<stroke android:width="1dp" android:color="#777777" />
</shape>
Ich möchte, dass mein Gridview so ist wie dieses
Nach der ersten Antwort von bakriOnFire