GridView的用法很多

請先參考

http://blog.csdn.net/hellogv/article/details/4567095

相關問題下面有些筆記


 

 如果GridView 的 itemClick沒反應!!!

可能是 GridView item的 layout元件有問題 

像我就是裡面擺了一個Button 怎麼debug就是itemclick沒反應

改成TextView就OK......


 

另外裡面沒有提到如果要實現 按下GridView Item時 Item的背景想換怎辦?

1.在drawable裡新增一個xml (舉例來說叫grid_selector),下面紅色的是你想換的背景圖檔

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">


<item android:state_focused="true" android:state_pressed="false"
android:drawable="@drawable/gridview_item_selected" />


<item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/gridview_item_selected" />


<item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/gridview_item_selected" />


</selector>

 

2.在GridView裡 增加屬性: android:listSelector="@drawable/grid_selector"

 

注意!!前提是 你給GridView item用的Layout中 不能設不透明的背景顏色或圖案

不然選中時 不會顯示 gird_item_bg 因為被蓋住了

 


 

 

如何讓GridView內的item變成長寬一樣的正方型

參考:http://blog.chengyunfeng.com/?p=465

 


 

GridView實現 水平+垂直滾動

參考:http://cookiesp.pixnet.net/blog/post/92452375


arrow
arrow
    文章標籤
    android gridview
    全站熱搜

    cookiesp 發表在 痞客邦 留言(0) 人氣()