Android 更改方向时碎片选项卡崩溃
错误消息:Android 更改方向时碎片选项卡崩溃,android,android-fragments,Android,Android Fragments,错误消息: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.basket/com.example.basket.MainActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.basket.MainActivity$TabContentFragme
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.basket/com.example.basket.MainActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.basket.MainActivity$TabContentFragment: make sure class name exists, is public, and has an empty constructor that is public
片段类:
public class TabContentFragment extends Fragment {
public TabContentFragment()
{
}
private String mText;
public TabContentFragment(String text) {
mText = text;
}
public String getText() {
return mText;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View fragView = inflater.inflate(R.layout.action_bar_tab_content, container, false);
mlistView= (ListView) fragView.findViewById(R.id.postListView);
getData(mText);
return fragView;
}
}
那个片段是内部类吗?如果是这样,您将需要使该内部类成为静态的 请看这里: