对超类的 onViewCreated() 方法的调用不会在片段的 onViewCreated() 方法中执行

The call to the onViewCreated() method of superclass doesn't gets executed in onViewCreated() method of fragment

我目前面临一个关于片段的问题。 大家知道在fragment的onViewCreated()方法中,第一条语句就是调用超类的onViewCreated()方法:

super.onViewCreated(view, savedInstanceState);

但是,上面的语句没有执行,因此,该语句下面的代码根本没有执行,我的应用程序一直崩溃。我不知道如何解决这个问题。 任何形式的帮助将不胜感激。

提前致谢!

public class FragmentAddWatchedTVShow extends ListFragment {

private Activity context;

public void setContext(Activity context) {
    this.context = context;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.frag_add_watched_tvshow, container, false);
    return view;
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    Log.d(AIntroductionScreen.DEBUGTAG, "Entered in onViewCreated");
//The above log statement is executed but after that nothing gets executed

    super.onViewCreated(view, savedInstanceState);/***THIS STATEMENT IS NOT EXECUTED***/

        /***None of the code below this gets executed***/

    String[] optionsString = getResources().getStringArray(R.array.watched_tvshow_options);

    List<AddOptionsItem> optionsList = new ArrayList<AddOptionsItem>();

    for (int i = 0; i < optionsString.length; i++){
        optionsList.add(new AddOptionsItem(optionsString[i]));          
    }

    AdapterAddWatchedTVShow adapter = new AdapterAddWatchedTVShow(context, optionsList);

    setListAdapter(adapter);


}

Logcat 输出:

08-29 23:11:22.670 658-658/? E/Sensors: new acc setDelay handle(0),ns(66667000) err! go to hwmsen
08-29 23:11:22.786 658-658/? E/RemoteViews: ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search <ANR Exception MSG   History>
08-29 23:11:22.788 658-658/? E/RemoteViews: ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search <ANR Exception MSG   History>
08-29 23:11:22.791 658-658/? E/RemoteViews: ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search <ANR Exception MSG   History>
08-29 23:11:22.791 658-658/? E/RemoteViews: ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search <ANR Exception MSG   History>
08-29 23:11:22.832 137-711/? E/AudioMTKHardware: setCommonParameters() still have param.size() = 1, remain param = "screen_state=on"
08-29 23:11:22.876 927-1018/? E/SQLiteLog: (13) statement aborts at 14: [INSERT INTO activity(start_time,duration,session_id,realtime,refer,name) VALUES (?,?,?,?,?,?)] 
08-29 23:11:22.903 927-1018/? E/SQLiteDatabase: Error inserting start_time=1472494282752 duration=0 session_id=28b85451-33d5-4962-8778-cebb5dbd5b61 realtime=174770322 refer=com.ibingo.launcher2.Launcher name=com.ibingo.launcher2.Launcher
                                                android.database.sqlite.SQLiteFullException: database or disk is full (code 13)
                                                    at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
                                                    at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:786)
                                                    at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
                                                    at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
                                                    at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1494)
                                                    at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1364)
                                                    at com.tendcloud.tenddata.aw.a(Unknown Source)
                                                    at com.tendcloud.tenddata.s.a(Unknown Source)
                                                    at com.tendcloud.tenddata.s.b(Unknown Source)
                                                    at com.tendcloud.tenddata.s.a(Unknown Source)
                                                    at com.tendcloud.tenddata.p.handleMessage(Unknown Source)
                                                    at android.os.Handler.dispatchMessage(Handler.java:110)
                                                    at android.os.Looper.loop(Looper.java:193)
                                                    at android.os.HandlerThread.run(HandlerThread.java:61)
08-29 23:11:22.941 11785-11785/? E/NetworkScheduler.SR: Invalid parameter app
08-29 23:11:22.941 11785-11785/? E/NetworkScheduler.SR: Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
08-29 23:11:22.986 658-658/? E/RemoteViews: ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search <ANR Exception MSG   History>
08-29 23:11:22.986 658-658/? E/RemoteViews: ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search <ANR Exception MSG   History>
08-29 23:11:23.502 927-1018/? E/CellLocation: create GsmCellLocation
08-29 23:11:33.766 137-7226/? E/AudioMTKHardware: setCommonParameters() still have param.size() = 1, remain param = "screen_state=off"
08-29 23:11:33.870 13321-13464/? E/SQLiteLog: (1) no such table: behavior
08-29 23:11:47.680 658-1100/? E/Sensors: new acc setDelay handle(0),ns(20000000) err! go to hwmsen
08-29 23:11:53.440 927-1018/? E/CellLocation: create GsmCellLocation
08-29 23:12:00.069 13321-13651/? E/SQLiteLog: (1) no such table: behavior
08-29 23:12:17.276 658-673/? E/Sensors: new acc setDelay handle(0),ns(20000000) err! go to hwmsen
01-01 00:00:00.000 0-0/? E/Internal: device '0123456789ABCDEF' not found

我终于找到了解决问题的方法!

根据ListFragment信息here:

ListFragment has a default layout that consists of a single list view. However, if you desire, you can customize the fragment layout by returning your own view hierarchy from onCreateView(LayoutInflater, ViewGroup, Bundle). To do this, your view hierarchy must contain a ListView object with the id "@android:id/list" (or list if it's in code)

在我的视图层次结构中,我有一个 ListView 对象,但没有为该对象指定 ID:@android: id/list,如上所述,我为该对象分配了一个全新的 ID。因此,抛出 运行 次异常,应用程序每次都崩溃。 无论如何,感谢所有立即回复并试图帮助我的人:)