在我的SlidingPaneLayout.The主视图中,我使用了一个ListView作为辅助视图,它是一个地图片段。ListView充当菜单。问题是在ListView上永远不会调用onItemClickedListener。即使是列表行在印刷机上也不会突出显示。看起来ListView不能获得焦点。
编辑:实际上,slidingPaneLayout.findFocus()显示的是android.widget.ListView。单击列表项时仍然没有结果。
下面是我的xml
<com.ziz.luke.custom_components.MySlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/slidingpanelayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/contactsList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000" >
</ListView>
<TextView
android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center_horizontal|center_vertical"
android:text="@string/noContacts" />
</RelativeLayout>
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</com.ziz.luke.custom_components.MySlidingPaneLayout>我怎么才能解决这个问题呢?
发布于 2013-06-19 08:08:05
我找到了答案。我使用的是SlidingPaneLayout的一个子类,其中我重写了
onInterceptTouchEvent(MotionEvent arg0)我试着做以下几件事:
user using the the slidingPaneLayout the using swiping。
因此,我在名为shouldSwipe的子类中创建了一个布尔值,以便从覆盖的方法返回。
导致问题的实现是:
@Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
return shouldSwipe;
}无论何时(shouldSwipe = true),它都会导致问题,因为它会告诉系统触摸事件已经被使用,并阻止它被传播。
我用这个解决了这个问题:
@Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
// TODO Auto-generated method stub
return shouldSwipe ?super.onInterceptTouchEvent(arg0):shouldSwipe;
}就这样。
发布于 2013-06-19 07:43:14
我刚刚使用SlidingPaneLayout创建了一个示例项目。
我没有使用任何地图,因为没有问题所在,所以我只是使用TextView来引用地图的位置。我确实使用了一个工作正常并接收点击监听程序的ListFragment。请从此处下载该项目:
https://dl.dropboxusercontent.com/u/33565803/StackOverFlowExamples/SlidingPaneLayoutExample.zip
如果您有任何配置问题,请让我知道它是否解决了您的问题;)
(我使用actionBarSherlock只是因为我习惯了,所以如果你愿意,你可以删除它)
发布于 2013-06-25 00:10:56
这只是一个建议,但也许使用NavigationDrawer作为导航列表抽屉会比重新发明轮子更容易。
http://developer.android.com/design/patterns/navigation-drawer.html
https://stackoverflow.com/questions/17137582
复制相似问题