我正在尝试添加日历的gridview作为listview的标题视图。它工作得很好,gridview完美展现。但现在问题是我无法点击日期!我不知道自己做错了什么.. rLayout是我的列表视图。 这是我的代码:
gridview= new GridView(getActivity());
AbsListView.LayoutParams gridParams= new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, (int)(height/2.5));
gridview.setLayoutParams(gridParams);
gridview.setNumColumns(7);
gridview.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id1) {
if(rLayout.getAdapter() == null){
}else{
rLayout.invalidate();
}
//some code
});
rLayout.addHeaderView(gridview);
这是我的xml文件:
<LinearLayout
android:layout_alignParentTop="true"
android:id="@+id/top_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/actionbar_image"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/calender_cal_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="horizontal"
android:gravity="center_vertical|left">
<ImageView
android:id="@+id/calender_cal_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/list"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:id="@+id/calender_head_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yadda"/>
</LinearLayout>
<LinearLayout
android:id="@+id/calender_new_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="horizontal"
android:gravity="center_vertical|right">
<ImageView
android:id="@+id/calender_new_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/new_yadda"
/>
</LinearLayout>
</LinearLayout>
<View
android:layout_below="@+id/top_header"
android:id="@+id/head_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#d3d3d3"/>
<RelativeLayout
android:layout_below="@+id/head_view"
android:layout_width="match_parent"
android:layout_height="30dp"
android:id="@+id/search_view"
android:background="@drawable/actionbar_image">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#dddddd" >
<EditText
android:id="@+id/searchView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Search"
android:paddingLeft="10dp"
android:singleLine="true"
android:background="@android:color/transparent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="invisible">
</EditText>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#7b898e"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Search" />
<TextView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:visibility="invisible"
android:text="Cancel"
android:textColor="#0D70B3" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/calender_lay"
android:layout_below="@+id/search_view"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/cla_topie">
<include
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/header"
layout="@layout/calender_top"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/line"
android:layout_below="@+id/cla_topie"
android:background="#cccccc"/>
<ListView
android:id="@+id/listie"
android:layout_below="@+id/line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="0dp"
android:divider="@android:color/transparent"
>
</ListView>
</RelativeLayout>
</RelativeLayout>