2012-06-01 10 views
2

모바일 및 태블릿 모두를위한 단일 응용 프로그램을 만들고 싶습니다. actiobBar sherlock 라이브러리를 사용하고 있습니다. SherlockFragmentActivity를 확장하는 MainActivity가 있습니다. MainActivity에는 탭만 들어있는 작업 표시 줄이 있습니다. 이제 각 탭에 조각을 연결하려고합니다.이 조각에는 두 조각 (목록 조각과 세부 조각)이 있어야합니다. 이 방법을 제안하십시오.ActionBar Sherlock, 작업 표시 줄 탭 및 단편

+1

했던 좋은 폴더에 레이아웃을 추가 당신은 이것을하는 방법을 이제까지 알아 낸다? – StuStirling

+0

도 관심이 있습니다. – Buffalo

답변

0

몇 가지 방법이 있지만, 단지 설명 할 것입니다.

탐색, ViewPager, TabAdapter를 사용할 수 있습니다 ... 아이디어는 의 조각을 추가합니다. 예를 들어

당신은보기 호출기로 TabAdapter 있습니다

private ViewPager   _viewPager; 
    private TabsAdapter   _tabsAdapter; 

    _tabsAdapter = new TabsAdapter(this, _viewPager); 
    _tabsAdapter.addTab(bar.newTab().setCustomView(getTabIndicator(getString(R.string.tle_tab_home), R.drawable.ic_menu_home)), FragmentAccueil.class, null); 
    _tabsAdapter.addTab(bar.newTab().setCustomView(getTabIndicator(getString(R.string.tle_tab_directory), R.drawable.tab_list_icon)), ContainerFragmentAnnuaire.class, null); 

ContainerFragmentAnnuaire은 당신이이 레이아웃

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <fragment class="com.example.android.ContainerFragmentAnnuaire" 
       android:id="@+id/list_frag" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"/> 
</FrameLayout> 

을 만들 것이다 핸드셋 예를 들어 조각

를 포함하는 레이아웃입니다 타블렛

<?xml version="1.0" encoding="utf-8"?> 
<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/frags"> 
    <fragment class="com.example.android.ContainerFragmentAnnuaire" 
      android:id="@+id/list_frag" 
      android:layout_width="@dimen/titles_size" 
      android:layout_height="match_parent"/> 
    <fragment class="com.example.android.ContainerFragmentDetail" 
      android:id="@+id/details_frag" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
</LinearLayout> 

단말기에 대한

고해상도/레이아웃/layout.xml

정제에 대한

고해상도/레이아웃 대형/layout.xml

관련 문제