다음과 같이 조각을 사용하기 위해 활동 기본 페이지를 작성하십시오.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.myproj.activity.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/container"
android:name="com.example.HomeFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
// UR 조각
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:clickable="true">
.....
.....
.....
</LinearLayout>
// JAVA 디자인
public class MainActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
...
// call MyFragment page here
}
.....
.....
.....
}
// 조각
public class MyFragment extends Fragment{
View view;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstantState){
view = inflater.inflate(R.layout.fragment_page,container,false);
...
return view;
}
}
페이지의 무한한 번호가에서 당신이 슬쩍 HTTP 수 있도록하는
ViewPager
내에서 조각을 사용하는 것입니다 : //www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/ –감사합니다. Majeed : – Melisa