ActionBarSherlockを使用してタブ ナビゲーション セットでアクション バーを実装しようとしています。現在、切り替え可能な 3 つのタブがあります。私のタブの 1 つで、ListView を実装しています。リスト内の項目の 1 つが選択されたときに、リストを別のフラグメントに置き換えて、選択の詳細ビューにする必要があります。
FragmentTransaction.replaceメソッドを新しい詳細フラグメントで呼び出すと、新しいフラグメントが表示されますが、ListView と重なっています。つまり、両方のフラグメントが表示されます。この種のナビゲーションは、ActionBar タブのナビゲーションを使用して可能ですか、それとも完全に間違った行にいますか? ここで本当に基本的な何かが欠けているように感じます。
タブ間の移動を処理するためにTabListenerを実装しているSherlockFragmentActivityがあります。ListView をホストするフラグメントはSherlockListFragmentを継承し、タップに応答してフラグメントを置き換えるためにOnItemClickListenerをアタッチしました。私はこのコードを使用しています
numbersList.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int i, long l) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(android.R.id.content, new NumberSelectedNavigationMenuFragment());
ft.commit();
}
});
ListView を置き換えるフラグメントは、現在、TextView を使用した基本的な LinearLayout にすぎません。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Test"
android:id="@+id/textView"/>
</LinearLayout>
私は元気で本当に立ち往生しているので、これで何か助けていただければ幸いです...