【发布时间】:2016-06-08 09:33:03
【问题描述】:
我有一个包含用于片段转换的框架布局的活动。框架布局正在加载一个片段,现在我想在框架布局上设置点击监听器。但是点击监听器工作正常。
这是包含片段框架布局的布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".FragmentActivity"
tools:showIn="@layout/app_bar_balance"
android:id="@+id/layout">
<FrameLayout
android:name="com.dd.cotech.Fragments.HomeFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragmentWindow"
tools:layout="@layout/fragment_home" />
这里是监听器编码
findViewById(R.id.fragmentWindow).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(FragmentActivity.this, "I am click", Toast.LENGTH_SHORT).show();
}
});
有什么帮助吗?
【问题讨论】:
-
你能解释一下你的问题吗
-
但是点击监听器工作正常 - 那么问题出在哪里?
-
抱歉打错了..click 监听器根本不工作。它没有捕捉到点击事件。
-
说明:我有一个活动,它具有用于加载片段的框架布局。当片段被加载时,我希望框架布局(包含加载的片段)是可点击的。在我设置点击监听器的情况下框架布局,但它没有捕获事件。
标签: android