Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>if i understood your question you need to create a customize an adapter.</p> <p>Create a new simple class like this which holds an string and a picture</p> <pre><code> Class ObjectHolder { int Image; String Title; } </code></pre> <p>and create a getter and setter for this two</p> <p>then create custom ArrayAdapter</p> <pre><code> Class CustomArrayAdapter extends ArrayAdapter&lt;ObjectHolder&gt; { public CustomArrayAdapter(Context C, ObjectHolder[] Arr) { super(C, R.layout.caa_xml, Arr); } @Override public View getView(int position, View v, ViewGroup parent) { View mView = v ; if(mView == null){ LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); mView = vi.inflate(R.layout.cpa_xml, null); } TextView text = (TextView) mView.findViewById(R.id.tv_caarow); ImageView image = (ImageView) mView.findViewById(R.id.iv_caarow); if(mView != null ) { text.setText(getItem(position).getText()); image.setImageResource(getItem(position).getImage()); return mView; } } </code></pre> <p>and create caa_xml.xml in res\layout\</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;ImageView android:id="@+id/iv_caarow" android:src="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;TextView android:id="@+id/tv_caarow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingBottom="15dip" android:layout_BottomOf="@+id/iv_caarow" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>and use it like this.</p> <pre><code> GridView GV= (GridView) findViewById(R.Id.gv); // reference to xml or create in java ObjectHolder[] OHA; // assign your array, any ways! mAdapter CustomArrayAdapter= CustomArrayAdapter(this, OHA); GridView.setAdapter(mAdapter); </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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