0

タブレットに2つのペインがあります。左はリスト、右は選択に基づいて各リストアイテムの詳細を表示します。右側のペインには、選択したリストアイテムごとに表示される一連のフラグメントがあります。問題は、シーケンスの2番目のフラグメントをクリックすると、3番目のフラグメントが表示される必要がありますが、最初に数秒間表示されてから、3番目のフラグメントが表示されます。これはすべて2番目のペインにあります1つのアイテムの2番目のペインのようです1つのフラグメントをクリック->2つのフラグメントを表示->2つのフラグメントをクリック->1を表示(数秒間)->3つのフラグメントを表示->

ただし、[1-]をクリック->[表示2-]->[2-]をクリック->[表示3->]のようになります。

フラグメントスタックを正しく設定するために何かをする必要があります

以下のコードを確認してください

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    if (selected_item != null)
        if (selected_item != v) {
            if (selct_item_bg_color != 0)
                selected_item.setBackgroundColor(Color
                        .alpha(selct_item_bg_color));
            else {
                int rgb = Utill.hex2decimal("D2");
                //int rgb3=Utill.hex2decimal("82");
                selected_item.setBackgroundColor(Color.rgb(rgb, rgb, rgb));
                //selected_item.setBackgroundColor(Color.GRAY);
                Log.e("", "DEFAULT NOT SELECTED");
            }
        }
    selected_item = v;
    selct_item_bg_color = v.getDrawingCacheBackgroundColor();


    selected_item.setBackgroundDrawable(v.getContext().getResources()
            .getDrawable(R.drawable.list_selector));
    Log.e("POSITION", "SELECTED ITEM POSITION : " + position);

    FragmentManager frMgr = this.getFragmentManager();
    FragmentTransaction xaction = frMgr.beginTransaction();
    switch (position) {
    case 0:
        ScheduleFragment sc_fragment = new ScheduleFragment();
        xaction.add(R.id.second_pane, sc_fragment, "itinerary");
        xaction.commit();
        break;
    case 1:
        ItineraryFragment it_fragment = new ItineraryFragment();
        xaction.add(R.id.second_pane, it_fragment, "itinerary");
        xaction.commit();
        break;
    case 2:
        VenueFragment vn_fragment = new VenueFragment();
        xaction.add(R.id.second_pane, vn_fragment, "Venue");
        xaction.commit();
        break;
    case 3:
        Bundle sendData=new Bundle();
        sendData.putString("URL", URL+utilclass.getMyDbHelper().getToken());
        sendData.putString("TITLE", "Search");
       //intent.putExtra("URL", URL+utilclass.getMyDbHelper().getToken());
        //intent.putExtra("TITLE", "Search");

        SearchWebFragment sw_fragment = new SearchWebFragment();
        sw_fragment.setArguments(sendData);
        xaction.add(R.id.second_pane, sw_fragment, "searchWeb");
        xaction.commit();
        break;

    default: Log.e("","Please Choose Right option");

    }
4

1 に答える 1

0
    I make it done by setting transaction to close using the below statement

    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);


   used as: 

    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    Fragment frag=new AbstractAuthorsFragment();
    transaction.replace(R.id.second_pane, frag);
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
    transaction.addToBackStack(null);
    transaction.commit();
于 2012-10-03T09:19:25.073 に答える