如何为自定义ViewPager充气

时间:2015-07-27 11:51:39

标签: android android-viewpager

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_vertical" >``

<com.example.sumit.myapplication.custom_viewpager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/pager_threee"
xmlns:android="http://schemas.android.com/apk/res/android" />
</LinearLayout>

相关的JAVA代码是:

import android.support.v4.view.ViewPager;

ViewPager vp;
private static double latitude = 0.0;
private static double longitude = 0.0;
private static String Country = "";
private static String Locality = "";
private static String AreaCode = "";
private static String My_Id = "0";

List<Fragment> fragments = new ArrayList<Fragment>();
Fragment frag_public_list;
Fragment frag_users_list;
Fragment frag_profile;
Fragment frag_photos;
adapter _adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main__users__page);

    frag_users_list = new users_list();

    Bundle bundle = new Bundle();
    bundle.putDouble("lat", latitude);
    bundle.putDouble("long", longitude);
    bundle.putString("Country", Country);
    bundle.putString("Locality", Locality);
    bundle.putString("AreaCode", AreaCode);
    bundle.putString("My_Id", My_Id);

    frag_users_list.setArguments(bundle);
    frag_public_list = new public_chat();

    fragments.add(frag_public_list);
    fragments.add(frag_users_list);

    vp = (ViewPager) findViewById(R.id.pager_threee);

我得到的例外是:

Java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sumit.myapplication/com.example.sumit.myapplication.Main_Users_Page}: android.view.InflateException: Binary XML file line #7: Error inflating class com.example.sumit.myapplion.custom_viewpager

0 个答案:

没有答案