2

私はこのようにメインのアクティビティを持っています:

public class EntryPoint extends SherlockFragmentActivity implements ActionBar.OnNavigationListener

また、ナビゲーション バーで 1 つの項目を選択したときにのみ切り替えたい 2 つのフラグメントがあるため、このメソッドは Nexus 7 (ターゲット バージョン 4.2.2) では機能しますが、Xperia Neo V (ターゲット バージョン 4.0.2) では機能しません。 3)。最初のフラグメントは問題なく表示されますが、別のフラグメントに変更してデバッグしたところ、onCreate または onCreateView メソッドが実行されません。そのため、フラグメント内のリストにアクセスしようとすると例外が発生します。奇妙なことに、Nexus 7 では完璧に動作しますが、SonyEriccson では問題ありません。

@Override
public boolean onNavigationItemSelected(int position, long id) {
    // When the given dropdown item is selected, show its contents in the
    // container view.

    int section = position + 1;
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    if (section == 1) {
        ft.add(R.id.container,new FavCityListFragment());

    } else if (section == 2) {
        ft.remove(getFav());
        ft.add(R.id.container,new CityListFragment());
        ft.addToBackStack(null);

    }
    ft.commit();
    return true;
}

2 つのフラグメントは次のようになります。

public class CityListFragment extends SherlockListFragment implements
    com.actionbarsherlock.widget.SearchView.OnQueryTextListener {

そしてコンテナ:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".EntryPoint"
tools:ignore="MergeRootFrame" >
</FrameLayout>
4

1 に答える 1

1

Ismael Reyesと話すと、彼は答えを見つけました。

この問題は Android にありますか: https://code.google.com/p/android/issues/detail?id=18594

それに答えるには:

「[...] src/com/example/android/supportv4/app/LoaderCustomSupport.java を編集して、OnQueryTextListener と onCreateOptionsMenu、onQueryTextChange、および onQueryTextSubmit 関数への参照を削除します [...]」 ダイアン ハックボーン

于 2013-06-12T10:39:14.987 に答える