嗨,我正在使用appcompat库在android下载版本(姜面包)中实现操作栏,在那里我需要用操作栏实现视图寻呼机但我的应用程序崩溃可以任何人建议实现视图寻呼机的想法用姜饼版的动作栏。
代码 -
public class MainActivity extends FragmentActivity {
ViewPager pager;
FrameLayout f;
mypageadapter pageradapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// kkk = getSupportActionBar();
// kkk.setTitle("jjjj");
f = (FrameLayout) findViewById(R.id.fram);
pager = (ViewPager) findViewById(R.id.pager);
List<Fragment> list_fragment = getFragment();
pageradapter = new mypageadapter(getSupportFragmentManager(),
list_fragment);
pager.setAdapter(pageradapter);
}
private List<Fragment> getFragment() {
// TODO Auto-generated method stub
List<Fragment> k = new ArrayList<Fragment>();
k.add(fragment1.newInstance("f1"));
k.add(fragment1.newInstance("f2"));
k.add(fragment2.newInstance("f3"));
k.add(fragment1.newInstance("f4"));
k.add(fragment1.newInstance("f5"));
return k;
}
}
Xml-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>