The previous fragment element is still active after adding a new fragment

My question can be described much better with this image. When I add a second fragment (2nd image) on top of the first fragment (1st image), the first fragment element (Spinner, EditText) is still active. Active middle touch in the same place, I see the drop-down menu coming down.

I cannot replace the fragment because I need to return in the same state where the user left the first fragment. Can someone tell me what the problem is.

I am adding a second snippet using broadcast because it needs to be called from the baseAdapter list. The code is as follows.

Listview onclick

view.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) 
        {
            Log.v("TAG", "Clicked: " + itemListPogo.get(position).getitemIdplato());

            Intent i = new Intent("start.fragment.action");
            i.putExtra("plateId", itemListPogo.get(position).getitemIdplato());
            mContext.sendBroadcast(i);
        }
    });

Reveiving

    mBroadcastReceiver = new BroadcastReceiver() 
    {
        @Override
        public void onReceive(Context context, Intent intent) 
        {
            Bundle extra = intent.getExtras();
            String plateId = extra.getString("plateId");  

            Fragment fragment = new PlateDetailsFragment(DashBoardActivity.this, Integer.parseInt(plateId));
            FragmentManager fragmentManager = (DashBoardActivity.this).getFragmentManager();
            fragmentManager.popBackStack("back", FragmentManager.POP_BACK_STACK_INCLUSIVE);

            fragmentManager.beginTransaction().add(R.id.frame_container, fragment).addToBackStack(plateId).commit();
        }
    };
    this.registerReceiver(mBroadcastReceiver, new IntentFilter("start.fragment.action"));

First two pic is first two fragment 3rd image is having the problem

+4
2

. / onClickListener. onClick. , . , .

. Linearlayout , onClickListener , .

+5

.

:

public static void insertFragment(Context context, int resId, Class<? extends Fragment> clazz, Bundle args, boolean stack)
    {
        if (context != null)
        {
            FragmentManager manager = ((FragmentActivity) context).getSupportFragmentManager();
            FragmentTransaction tx = manager.beginTransaction();

            if (stack)
            {
                tx.addToBackStack(null);
            }
            else
            {
                Fragment fragment = manager.findFragmentById(resId);
                if (fragment != null)
                    tx.remove(fragment);
            }
            tx.add(resId, Fragment.instantiate(context, clazz.getName(), args));
            tx.commitAllowingStateLoss();
        }
    }
0

All Articles