1
在我的Android 應用。但它不顯示內容。 我FragmentActivity是的Android viewpager不顯示我使用<strong>viewpager</strong>和<strong>FragmentActivity</strong>佈局
public class DropPickup extends FragmentActivity {
private DPAdapter myAdapter;
private ViewPager myPager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myAdapter = new DPAdapter(getSupportFragmentManager());
myPager = (ViewPager) findViewById(R.id.dp_viewpager);
myPager.setAdapter(myAdapter);
}
public static class MyAdapter extends FragmentPagerAdapter {
public MyAdapter(FragmentManager fm) {
super(fm);
}
@Override
public int getCount() {
return 3;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return new PickUpFragment();
case 1:
return new DropFragment();
default:
return null;
}
}
}
}
和我的網頁適配器如下。
public DPAdapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public Fragment getItem(int position) {
// TODO Auto-generated method stub
switch (position) {
case 0:
return new PickUpFragment();
case 1:
return new DropFragment();
default:
return null;
}
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 2;
}
}
這是我的一個片段
public class DropFragment extends Fragment {
TableLayout DTbl;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View viewx=inflater.inflate(R.layout.fragment_drop, container, false);
DTbl = (TableLayout) viewx.findViewById(R.id.dpp_tbl_prs_tbl);
//return super.onCreateView(inflater, container, savedInstanceState);
return viewx;
}
}
這是我的佈局來看尋呼機
<android.support.v4.view.ViewPager
android:id="@+id/dp_viewpager"
android:layout_width="wrap_content"
android:layout_height="fill_parent" />
所以有人可以幫我圖出來的公關oblem。謝謝 !!!!
它是我的FragmentActivity的問題嗎? –