3

Android 4.0.3 용 앱에 액션 바가 있습니다. 모든 탭에는 조각이 변경되지만 탭은 변경되지 않는 일부 버튼이 있습니다. http://developer.android.com의 공식 개발자 가이드를 따랐지만 작동하지 않습니다.Android 액션 바?

이 내가 원하는 무엇인가 :이 작업 표시 줄 셜록과의 상호 작용이 유형의 수

enter image description here

인가?

+0

현재 탭에서 내비게이션을하고 싶다고 생각한다면? ViewPager가 어댑터를 사용하고 있기 때문에 간단한 방법을 생각하지 않습니다. ■ ActionBarSherlock은 공식 ActionBar와 동일하며 이전 버전의 Android와 호환됩니다. 이전 버튼을 클릭하여 새로운 활동을 열 수 없습니까? –

+0

예, 정확하게 필요한 것입니다! 나는 Activity를 사용하기도하지만 불행히도 나는 할 수 없다. 나는 변호사를 지킬 의무가있다. – user1738741

+0

코드를 게시 할 수 있습니까? ViewPager 및 ViewPager 어댑터? 솔루션은 여기에 :) –

답변

2

필자는 tab 콜백 클래스 메서드 onTabSelected (Tab tab, FragmentTransaction ft)를 적절히 재정 의하여 필요한 탭 동작을 지정할 수 있다고 생각합니다. 모양이 비슷 함

 public void onTabSelected(Tab tab, FragmentTransaction ft) { 
     // Check if the fragment is already initialized 
     if (mFragment == null) { 
      // If not, instantiate and add it to the activity 
      mFragment = Fragment.instantiate(mActivity, mClass.getName()); 
      ft.add(R.id.realtabcontent, mFragment, mTag); 
     } else { 
      //Here we look if current fragment aren't default fragment for this tab 
      //Remember that detached fragments are still managed by system, so manage it the way u need 
      // If it exists, simply attach it in order to show it 
      // ft.attach(mFragment); 
      if (mFragment.getTag().equals("defaultFragment")) 
       ft.show(mFragment); 
      else { 
       ft.detach(mFragment); 

       mFragment = fragmentManager.findFragmentByTag("defaultFragment"); 
       if (mFragment == null) 
        mFragment = Fragment.instantiate(mActivity, mClass.getName()); 
       ft.add(R.id.realtabcontent, mFragment, "defaultFragment"); 
      } 
     } 
    } 
+0

mFragment가 탐색 조각 또는 탭 하나? 이것은 내 코드입니다. http://stackoverflow.com/questions/12843944/actionbar-and-fragments-onics 4-0-3 – user1738741