listview的item 是horizontalscrollview ,horizontalscrollview 里面包含button,item现在无法实现监

阿泽七 2016-07-26 02:45:46
listview的item 是horizontalscrollview ,horizontalscrollview 里面包含button,item现在无法实现监,布局文件里面已经加入的 android:descendantFocusability="blocksDescendants",但是依旧无法点击。onTouch在listview里面根本无法显示坐标点,怎么决解啊。。。求大神啊指点啊。。。
...全文
120 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yayayaiii 2016-07-27
  • 打赏
  • 举报
回复
package com.example.listviewforscrollview; import android.content.Context; import android.util.AttributeSet; import android.widget.ListView; //次控制是Scrollview,子控件是Listview。 public class ListViewForScrollView extends ListView { public ListViewForScrollView(Context context) { super(context); // TODO Auto-generated constructor stub } public ListViewForScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public ListViewForScrollView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override /** * 重写该方法,达到使ListView适应ScrollView的效果 */ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } } <!--这个是垂直滑动 --> <com.example.gridviewforscrollview.GridViewForScrollView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="50dp" android:background="#DCDCDC" android:horizontalSpacing="1dp" android:verticalSpacing="1dp" android:numColumns="4" android:text="@string/hello_world" /> 这样就可以监听点击事件了。

80,490

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧