레이아웃에 ViewPager가있는 활동이 있습니다.조각 (중첩 된 조각)에 대한 ID xxx에 대한보기를 찾지 못했습니다.
각 탭마다 하나씩 표시되는 두 개의 조각이 있습니다. 조각의
하나가 다른 조각을 호스팅 할 수 있도록 설계되었습니다 -이 fragment_customer_main
커지는 CustomerMainFragment
입니다 :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lyt_customer_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/fragment_customer_content"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
이 다음 fragment_customer_search
커지는 FrameLayout
에 CustomerSearchFragment
을 추가합니다.
java.lang.IllegalArgumentException: No view found for id 0x7f080006 (com.chrisbeckyapps.sample:id/fragment_customer_content) for fragment CustomerDetailFragment{4280b0b8 #0 id=0x7f080006}
I : 나는 다음과 같은 오류를 얻을 버튼을 클릭 한 후
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Button btnSearch1 = (Button) view.findViewById(R.id.button1);
if (btnSearch1 != null) {
btnSearch1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// This is important bit
Fragment customerDetailFragment = new CustomerDetailFragment();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.addToBackStack(null);
transaction.replace(R.id.fragment_customer_content, customerDetailFragment).commit();
}
});
}
}
:
CustomerSearchFragment
또한 버튼을 눌러에 상세 조각에 대한 검색 조각을 전환 할 수있는 다음과 같은 재정이 있습니다 파편에 익숙하지 않고 개념을 이해하고 있지만, 나는 이것으로 난처 해 해요. 원래 검색 조각을 호출기로 곧바로 가져 왔지만 세부 조각으로 바꾸면 검색 결과가 더 잘 보였고 내 연구 결과 더 나은 솔루션이되었습니다.
나는 검색 논리를 CustomerMainFragment
으로 옮기려고하는데 궁금해했으나 이는 많은 논리를 연결한다는 것을 의미하며 논리를 조각 안에 삽입 할 수 있다고 생각했습니다.
제안 사항?
에
getChildFragmentManager
에서 변경했다? –