私の親には、 とLinearlayout1の 2 つの子フレーム レイアウトが含まれていFrameLayout1ますFrameLayout2。
はのFrameLayout1上にありFrameLayout2ますが、 の半分しかカバーしていませんFrameLayout2。
私はいくつかと交換FrameLayout1し、いくつかfragment1と交換FrameLayout2しましたfragment2。
をクリックするFrameLayout2と、FrameLayout1が非表示になります。しかし、これは起こっていません。
そのために次のことを試しました。
userDetails.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.userDetails, container, false);
topLayout = (LinearLayout) getActivity().findViewById(R.id.FrameLayout1);
bottomLayout = (LinearLayout) getActivity().findViewById(R.id.FrameLayout2);
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
topLayout.setVisibility(View.GONE);
}
});
}
ビューの onClick リスナーがクリック時に呼び出されないこともわかりました。
アップデート:
activity_main.xml :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/FrameLayout1"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/FrameLayout2"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="match_parent" />
</FrameLayout>