질문이 명확하지 않은 경우 죄송합니다. 내 앱에는 acion bar에 3 개의 탭이 있으며 각 탭에는 두 개의 조각으로 구성된 별도의 XML 레이아웃이 있습니다. 첫 번째 두 탭의 레이아웃은 비슷하지만 세 번째 탭에는 별도의 XML 레이아웃이 있습니다. 첫 번째 탭에는 나머지 호출을 만들고 데이터를 표시합니다. 왼쪽 부분에는 폴더 목록이 표시되고 오른쪽 부분에는 파일 목록이 표시됩니다. Tab2는 동일하지만 SD 카드의 데이터를 표시합니다. 기본적으로 파일 관리자입니다.파편과 오른쪽 디자인
세 번째 탭은 처음 두 조각과 완전히 다른 검색 페이지입니다.
다음은 제 질문입니다.
- 각각의 탭마다 다른 활동을 사용할 수 있는지 알고 싶습니다. 이것이 올바른 디자인입니까?
- 주요 액티비티를 사용하여 조각에 필요한 레이아웃을 만들었으므로 이제는 세 번째 탭에 문제가 있습니다. 이유는 XML 레이아웃이며 조각 클래스 (코드)가 세 번째 탭에서 완전히 변경되었습니다. 다음은 xml 파일의 내용입니다. 처음 두 개의 탭에 대한
레이아웃 :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/frags1">
<fragment class="TitlesFragment"
android:id="@+id/browse_title"
android:visibility="gone"
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_height="match_parent" android:layout_width="320dip"/>
<fragment class="ContentFragment"
android:id="@+id/browse_content"
android:visibility="gone"
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_height="match_parent" android:layout_width="match_parent">
</fragment>
</LinearLayout>
Layout for the third tab:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/settings"
android:background="@drawable/window"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="true">
<fragment class="SearchFragment"
android:id="@+id/search_title"
android:visibility="gone"
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_width="700dp"
android:paddingRight="5dip"/>
<fragment class="SearchContentFragment"
android:id="@+id/searchbrowse_content"
android:visibility="gone"
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
그래서 tab3에 (검색) UI를 제대로 renedered되는 첫 번째 탭에서 클릭,하지만 난 TAB1에 tab3에에서 돌아올 수 없을 때. 이 문제를 해결하기 위해 XML 파일의 조각을 기본 활동 코드에서 옮겼습니다. 이것이 올바른 설계인지 아닌지 확실하지 않기 때문에 걱정됩니다.
또한 아래는 코드 스 니펫입니다.
switch(nTabSelected)
{
case ConnectedConstants.BROWSE:
if (getFragmentManager().findFragmentById(R.id.browse_title) == null)
{
setContentView(CreateMainLayout());
}
TitlesFragment titleFrag = (TitlesFragment) getFragmentManager()
.findFragmentById(R.id.browse_title);
titleFrag.resetCurPosition();
titleFrag.setCategory(nTabSelected);
if (bLoggedin) {
titleFrag.selectPosition(0);
}
break;
사용자가 탭을 클릭 할 때마다 해당 perticulat 탭에 대해 XML이 부풀려집니다. 다음 질문은 내가 tab1 및 tab2에 대한 목록 조각을 사용하고 있기 때문에 나머지 부분에서 tab1 조각을 호출하기 위해 나머지 호출을 사용하여 서버에서 데이터를 가져 왔다고 말했습니다. setListAdapter를 수행하기 만하면됩니다. 백 스택을 구현할 수 있습니다. 또는 모든 목록 항목을 클릭 할 때마다 새 프래그먼트 트랜잭션이 필요하고 백 스택에 프래그먼트를 추가하십시오.
제 질문에 여전히 불분명하게 들리는 경우 알려주세요.
감사합니다, Harsha에
우리는 그 일을했다
더 구체적이어야합니다. 질문의 범위를 좁히십시오. –
도움을 받으려면 언급 한 "충돌 문제"에 관한 logcat 출력을 게시하십시오. – Tapirboy
질문이 명확하지 않은 경우 죄송합니다. – user1031459