1. Buat class
2. Script HistoriFragmentActivity.java
package thefly.org.histori;
import go_antri.org.R;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.view.Menu;
public class HistoriFragmentActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.histori_fragment); //Layout dari form untuk fragment
//inisialisi
ViewPager pager = (ViewPager) findViewById(R.id.pager);
//ambil framnet manager
FragmentManager fm = getSupportFragmentManager();
//inisalisasi histori tab adapter
HistoryTabAdapter pagerAdapter = new HistoryTabAdapter(fm);
/** Setting the pagerAdapter to the pager object */
pager.setAdapter(pagerAdapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//getMenuInflater().inflate(R..activity_main, menu);
return true;
}
}
3. Buat tampilannya di folder layout histori_fragment.xml
<RelativeLayout 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.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<android.support.v4.view.PagerTabStrip
android:id="@+id/pager_tab_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="#ff007f"
android:textColor="@android:color/black"
/>
</android.support.v4.view.ViewPager>
</RelativeLayout>
0 komentar:
Posting Komentar