android 自定义listview
android 自定义listview的onitemclick及gridview问题
1、关于gridview在自定义listview不能完全显示图片的解决办法。
//重写onmeasure方法
public class MyGridView extends GridView{
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// TODO Auto-generated method stub
int expandSpec = MeasureSpec.makeMeasureSpec(
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
2、关于自定义listview不响应onitemclick事件的可能解决办法。(不响应有多重原因,仅贴出我的。百度上的解决方法一大抄,错别字都不带改的,看了都是眼泪。)
//适配器的布局中,在根目录下添加 android:descendantFocusability="blocksDescendants"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants"
>
<!---
//各种控件,布局
-->
</LinearLayout >