在我的Android應用程序,我有一個按鈕的GridView佈局。問題是,我無法正確設置按鈕上的焦點(我的意思是光標,由Android設備上的操縱桿控制)。我可以描述我的問題有一個畫面:重點在GridView佈局
我使用LayoutInflater動態設置按鈕到GridView中的代碼BaseAdapter。在代碼中,我設置了按鈕的文本,圖像(CompoundDrawable)和背景顏色,因爲我的按鈕像複選框一樣工作(藍色背景表示選中)。
看起來程序是關注網格域而不是按鈕本身。我的意思是像桌子的單元格而不是桌子上的按鈕。因爲焦點顏色是默認的(綠色),但是我在選擇器中設置了藍色。重點新聞也不起作用。焦點顯然在按鈕後面,超出按鈕的界限。請有人幫我解決這個問題嗎?我的XML佈局代碼:
的main.xml:
...
<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">
</GridView>
...
channel.xml:
<Button
android:id="@+id/channel"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:gravity="center_horizontal"
android:background="@color/willBeSetInAdapter" <!-- white/blue/darkblue focus background -->
android:drawableTop="@drawable/willBeSetInAdapter" <!-- icon -->
android:drawablePadding="0dip"
android:text="WillBeSetInAdapter" <!-- label text -->
android:textColor="@color/text_container_main"
android:textSize="12sp"
android:focusable="true"
android:focusableInTouchMode="false">
</Button>
我試圖設置按鈕焦點參數應用,並在GridView和嘗試了很多東西,但不幸的是,它仍然不起作用:(