错误讯息:
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;
}
}
答案 0 :(得分:0)
该片段是内部类吗?如果是这样,您将需要使该内部类静态。