1

좋아, 먼저 해보겠습니다. 아무도 내가 그 ViewPager 레이아웃에이 클래스 MainActivity에서Android : ViewPager를 사용하여 MainActivity에서 RelativeLayout 채우기

public class ResultBar extends FragmentActivity implements ActionBar.TabListener { 
AppSectionsPagerAdapter mAppSectionsPagerAdapter; 
ViewPager mViewPager; 

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.pagerlayout); 
    ... 

를 삽입하는 방법을 알고 있나요?

+0

명확하게 이해합니다. MainActivity에 ResultBar를 추가하고 싶습니까? –

+0

예 주요 활동을 레이아웃에로드하려는 경우 – user2212461

+0

글쎄, 내 대답이 유용 했습니까? –

답변

1

하나의 활동을 다른 활동에 추가 할 수 없습니다. 안드로이드는이 기능을위한 조각을 사용합니다. here 또는 here에 대해 몇 가지를 배울 수 있습니다.

그래서 당신은 또한 당신의 MainActivityFragmentActivity, MainActivityContentFragment에 이전 콘텐츠를 변환, 당신의 ResultBarFragment로 변환하고 MainActivityResultBarFragment를 추가 할 수 있습니다. 이것은 당신의 주요 활동 layour 모습 수있는 방법입니다 :

/res/layout/main_activity.xml : 여기

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" android:layout_height="match_parent"> 

    <fragment class="com.example.MainActivityContentFragment 
      android:id="@+id/content" android:layout_weight="1" 
      android:layout_width="0px" android:layout_height="match_parent" /> 

    <fragment class="com.example.ResultBarFragmnt 
      android:id="@+id/result_bar" android:layout_weight="1" 
      android:layout_width="0px" android:layout_height="match_parent" /> 

</LinearLayout> 

또한 ResultBarFragment 모습 수있는 방법 니펫을 : 그냥 나를 위해

public class ResultBarFragment extends Fragment 
{ 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
    { 
     return inflater.inflate(R.layout.pagerlayout, container, false); 
    }