맥주 목록이 있습니다. 내 주요 활동은 입니다. MainActivity입니다. 그 중 하나를 클릭 할 때마다 맥주 정보를 보여주는 새로운 화면을 표시하려고합니다.조각 만 표시하는 방법
내 목록이 어떻게 표시되며 내 조각을 만들기 위해 실행되는 코드입니다.
@Override
public void onClick(View view) {
// Data to send to fragment
Beer beer = displayedList.get(getAdapterPosition());
Bundle bundle = new Bundle();
bundle.putParcelable("Beer", beer);
bundle.putParcelableArrayList("BeerList", (ArrayList<? extends Parcelable>) beerList);
// Begin the transaction
FragmentTransaction ft = context.getSupportFragmentManager().beginTransaction();
// Replace the contents of the container with the new fragment
BeerInfoFragment beerInfoFragment = new BeerInfoFragment();
beerInfoFragment.setArguments(bundle);
ft.replace(R.id.frame_layout, beerInfoFragment);
// or ft.add(R.id.your_placeholder, new FooFragment());
// Complete the changes added above
ft.commit();
}
}
그러나, 대신 새 화면에 맥주의 정보를 표시하는, 내가 동시에 두 레이아웃을 가지고 :
질문 : 어떻게 할 수 두 가지 대신 단편 레이아웃 만 표시하도록 하시겠습니까?
이 내 MainActivity 레이아웃이 같은 모습입니다 :
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
두 조각이 필요합니다. 첫 번째 것은 목록을 표시하고 두 번째 것은 이미 가지고 있음 –
조각 레이아웃에 배경색을 추가하려고 했습니까? –
@Pavneet_Singh 그 것에 대해 검색해 보겠습니다. AlbertoMéndez 여전히 목록 스크롤바를 사용하여 스크롤 할 수 있습니다. MainActivity 레이아웃을 숨길 수 있더라도 하나의 레이아웃 만 표시하고 싶습니다. – deko