主要活动(片段活动)
public class RestaurantDetails extends FragmentActivity {
private static final String TAG = "ImageGridActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.restaurantinfo);
inicialize();
/* Adding fragment in a relativelayout */
if (getSupportFragmentManager().findFragmentByTag(TAG) == null) {
final FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
ft.add(R.id.fragment_container, new MapFragment(), TAG);
ft.commit();
}
/* Pager on bottom */
mPager.setCurrentItem(getIntent().getExtras().getInt("idRest"));
}
Run Code Online (Sandbox Code Playgroud)
布局主要活动
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="212dp"
tools:context=".MapFragment" />
<android.support.v4.view.ViewPager
android:id="@+id/pagerDetails"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
地图片段
public class MapFragment extends …Run Code Online (Sandbox Code Playgroud) java android android-layout android-fragments android-viewpager