Note that there are some explanatory texts on larger screens.

plurals
  1. POFocus in GridView layout
    primarykey
    data
    text
    <p>In my Android app, I have a GridView layout with a set of Buttons. The problem is, that I can't set properly the focus (I mean cursor, controlled with joystick on the Android device) on the buttons. I can describe my problem with a picture:</p> <p><img src="https://i.stack.imgur.com/DaR15.png" alt="Focus in GridView layout"></p> <p>I set the Buttons to the GridView dynamically in the code in BaseAdapter using LayoutInflater. In the code, I set button's text, image (CompoundDrawable) and background color, because my buttons works like a checkboxes (blue background means checked). </p> <p>It seems like the program is focusing the grid field and not the button itself. I mean something like cell of table and not the button in table. Because the focus color is default (green) however I set the blue color in selector. Focus press also doesn't work. And the focus is evidently behind the button, out of button's bounds. Can somebody help me with this trouble please? Code of my XML layouts:</p> <p>main.xml:</p> <pre><code>... &lt;GridView android:id="@+id/channels" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="6dip" android:verticalSpacing="10dip" android:horizontalSpacing="10dip" android:numColumns="auto_fit" android:columnWidth="60dip" android:stretchMode="columnWidth" android:gravity="center" android:background="@color/container_main"&gt; &lt;/GridView&gt; ... </code></pre> <p>channel.xml:</p> <pre><code>&lt;Button android:id="@+id/channel" android:layout_height="fill_parent" android:layout_width="fill_parent" android:gravity="center_horizontal" android:background="@color/willBeSetInAdapter" &lt;!-- white/blue/darkblue focus background --&gt; android:drawableTop="@drawable/willBeSetInAdapter" &lt;!-- icon --&gt; android:drawablePadding="0dip" android:text="WillBeSetInAdapter" &lt;!-- label text --&gt; android:textColor="@color/text_container_main" android:textSize="12sp" android:focusable="true" android:focusableInTouchMode="false"&gt; &lt;/Button&gt; </code></pre> <p>I tried to set focus parametres in Button and also in GridView and tried a lot of things, but unfortunately it still doesn't work :(</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.
    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