Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make customAdapter fill gridview height
    primarykey
    data
    text
    <p>I am working on Sudoku app. The layout is 9x9 GridView. Each GridView include 9 Textviews by customAdapter. I want to make the 9 TextViews to fill the height of each GridView. How?</p> <p>This is what I am having now <img src="https://i.stack.imgur.com/LvY7l.png" alt="enter image description here"></p> <p>Here is myGridAdapter:</p> <pre><code>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; } ..... } </code></pre> <p>This is the XML for each text item </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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" &gt; &lt;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" &gt; &lt;/TextView&gt; &lt;/LinearLayout&gt; </code></pre> <p>This is the shape for each TextView</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;shape xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"&gt; &lt;solid android:color="#FFFFFF"/&gt; &lt;stroke android:width="1dp" android:color="#777777" /&gt; &lt;/shape&gt; </code></pre> <p>I want my Gridview to be like this one <img src="https://i.stack.imgur.com/pCWNB.png" alt="enter image description here"></p> <p>After applying the first answer of bakriOnFire</p> <p><img src="https://i.stack.imgur.com/DK39m.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload