目前,我有从我从返回一个自定义的ListView一个ListFragment OnCreateView()
包括下文)。
我的问题是当只有视图中的几个项目,你可以看到在后台进度指示器。 setListShown(true)
隐藏进度指示器,但返回的自定义时查看它导致一个IllegalStateException。
一个方法来隐藏进度指示器任何想法?
@Override
public ListView onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
ListView lv = new ListView(this.getActivity());
lv.setId(android.R.id.list);
lv.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
lv.setStackFromBottom(true);
return lv;
}
编辑:我也试着膨胀的观点,但它返回相同的IllegalStateException异常。
@Override
public void onActivityCreated (Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
setListShown(true);
}
@Override
public ListView onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
ListView lv = (ListView) inflater.inflate(R.layout.chat_fragment, container, false);
lv.setId(android.R.id.list);
return lv;
}
08-02 12:58:19.552: E/AndroidRuntime(27844): FATAL EXCEPTION: main
08-02 12:58:19.552: E/AndroidRuntime(27844): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.wisc.ACHESS/edu.wisc.ACHESS.ChatMessageActivity}: java.lang.IllegalStateException: Can't be used with a custom content view
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.os.Handler.dispatchMessage(Handler.java:99)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.os.Looper.loop(Looper.java:137)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-02 12:58:19.552: E/AndroidRuntime(27844): at java.lang.reflect.Method.invokeNative(Native Method)
08-02 12:58:19.552: E/AndroidRuntime(27844): at java.lang.reflect.Method.invoke(Method.java:511)
08-02 12:58:19.552: E/AndroidRuntime(27844): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-02 12:58:19.552: E/AndroidRuntime(27844): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-02 12:58:19.552: E/AndroidRuntime(27844): at dalvik.system.NativeStart.main(Native Method)
08-02 12:58:19.552: E/AndroidRuntime(27844): Caused by: java.lang.IllegalStateException: Can't be used with a custom content view
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.support.v4.app.ListFragment.setListShown(ListFragment.java:282)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.support.v4.app.ListFragment.setListShown(ListFragment.java:258)
08-02 12:58:19.552: E/AndroidRuntime(27844): at edu.wisc.ACHESS.fragments.ChatFragment.onViewCreated(ChatFragment.java:19)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:885)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:523)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.app.Activity.performStart(Activity.java:5018)
08-02 12:58:19.552: E/AndroidRuntime(27844): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
08-02 12:58:19.552: E/AndroidRuntime(27844): ... 11 more