Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 带有viewpagerindicator库的片段:can';t实例化类com.rbrlnx.controlles.FragmentAdapter;没有空构造函数_Android_Android Fragments_Android Viewpager - Fatal编程技术网

Android 带有viewpagerindicator库的片段:can';t实例化类com.rbrlnx.controlles.FragmentAdapter;没有空构造函数

Android 带有viewpagerindicator库的片段:can';t实例化类com.rbrlnx.controlles.FragmentAdapter;没有空构造函数,android,android-fragments,android-viewpager,Android,Android Fragments,Android Viewpager,我不明白android中片段的用途,我使用的是viewpagelibrary(https://github.com/JakeWharton/Android-ViewPagerIndicator) 我试着用片段来描述这个。我有此代码的碎片活动: public class FragmentosActivity extends FragmentActivity { private PagerAdapter mPagerAdapter; @Override public voi

我不明白android中片段的用途,我使用的是viewpagelibrary(https://github.com/JakeWharton/Android-ViewPagerIndicator) 我试着用片段来描述这个。我有此代码的碎片活动:

public class FragmentosActivity extends FragmentActivity {

    private PagerAdapter mPagerAdapter;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(R.layout.fragmentos_layout);

        // initialsie the pager
        this.inicializaPaginas();
    }

        //Este metodo inicia todos los fragments
private void inicializaPaginas() {



     FragmentAdapter adapter = 
                new FragmentAdapter(getSupportFragmentManager());
        adapter.addFragment(new Mapa());
        adapter.addFragment(new Cercanos());

    ViewPager pager = (ViewPager) super.findViewById(R.id.indicator);
    pager.setAdapter(this.mPagerAdapter);

}
碎片适配器

public class FragmentAdapter extends FragmentPagerAdapter {

        List<Fragment> fragments = null;
public FragmentAdapter(FragmentManager fm) {
    super(fm);
    fragments = new ArrayList<Fragment>();
}
public void addFragment(Fragment fragment){
    fragments.add(fragment);
}
@Override
public Fragment getItem(int arg0) {
    return fragments.get(arg0);
}
@Override
public int getCount() {
    return fragments.size();
}


     }
而碎片的布局是:

?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <com.viewpagerindicator.TitlePageIndicator
        android:id="@+id/indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        style="@style/Widget.IndicadorTitulo" />
        /> 
</LinearLayout>
?xml version=“1.0”encoding=“utf-8”>
/> 
而mapa.class和cercanos.class是无代码扩展片段的类

应用程序没有显示任何内容,它崩溃并显示“无法实例化类com.rbrlnx.controlles.FragmentAdapter;没有空构造函数”

我正在寻找片段示例教程,但所有这些都很难学习和翻译(我是西班牙语),有人能帮我吗?如果你有简单的代码学习片段将其完美。
谢谢

您的问题已经解决了吗

您的留言:

无法实例化类com.rbrlnx.controlles.FragmentAdapter;没有空构造函数

看起来你可能没有:

  • 公共静态HistoryFragment newInstance(上下文上下文,TextView textViewSubText)
  • 已创建ActivityState上的公共无效(Bundle savedInstanceState)。。。 或者
  • CreateView上的公共视图(布局、充气机、视图组容器、捆绑包保存状态)
方法

你能发布你的stacktrace消息吗? 干杯
迈克,你的问题已经解决了吗

您的留言:

无法实例化类com.rbrlnx.controlles.FragmentAdapter;没有空构造函数

看起来你可能没有:

  • 公共静态HistoryFragment newInstance(上下文上下文,TextView textViewSubText)
  • 已创建ActivityState上的公共无效(Bundle savedInstanceState)。。。 或者
  • CreateView上的公共视图(布局、充气机、视图组容器、捆绑包保存状态)
方法

你能发布你的stacktrace消息吗? 干杯
迈克

没人?我在谷歌笔记本里什么也没找到?我在谷歌里什么也没找到
?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <com.viewpagerindicator.TitlePageIndicator
        android:id="@+id/indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        style="@style/Widget.IndicadorTitulo" />
        /> 
</LinearLayout>