How to call getFragmentManager from base adapter in android
<p>In my app i am having the list view populated using the <code>base adapter</code> inside <code>fragment class</code>.Here i want to call the another fragment by clicking the button from base adapter i did some thing but it was showing the <code>nullpointer exception</code> because of fragment manager
can any one tell me how to call <code>fragment manager</code> from <code>base adapter</code> in android
this is the code i have inside my <code>base adapter</code> </p>

<pre><code>package com.adapter.sales;

import java.util.List;

import android.annotation.SuppressLint;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.lotus.com.androidmis.R;
import android.lotus.com.androidmis.Sales;
import android.lotus.com.androidmis.Salesteam;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lotus.mis.modle.UserDetails;


public class Emp_Spinner_Adapter extends BaseAdapter {

    Context context;
    List&lt;UserDetails&gt; objects;
    String Flaglist = "3";
    FragmentManager fragment;

    public Emp_Spinner_Adapter(Context context, int resource,
            List&lt;UserDetails&gt; objects) {
        this.context = context;
        this.objects = objects;

    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub

        return objects.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return objects.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View Row = LayoutInflater.from(context).inflate(
                R.layout.layout_adapter_sales_team_members, null);


        TextView txt_item = (TextView) Row.findViewById(R.id.txt_item);
        ImageView img_count = (ImageView) Row.findViewById(R.id.img_count);
        ImageView details_sales = (ImageView)Row.findViewById(R.id.img_details_sales);
        final UserDetails UserDetails_item = (UserDetails) objects
                .get(position);

        txt_item.setText("  " + UserDetails_item.getUserName());

        final int temp_count = Integer
                .valueOf(UserDetails_item.GetWorkStatus());
        if (temp_count &gt; 0) {
            img_count.setImageResource(R.drawable.ic_lotus_team);
            img_count.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {

                    String username = UserDetails_item.getUserName();

                    //Intent i = new Intent(context, Sales.class);
                    Bundle bundle = new Bundle();
                    bundle.putString("key_username",
                            UserDetails_item.getUserName());
                    bundle.putString("key_userid", UserDetails_item.getUserID());
                    bundle.putString("report_username", Salesteam.txt_levels
                            .getText().toString());
                    bundle.putString("key_FlagList", Flaglist);
                    Salesteam sales_team = new Salesteam();
                    sales_team.setArguments(bundle);
                    FragmentTransaction xfragmentTransaction = fragment.beginTransaction();
                    xfragmentTransaction.replace(R.id.containerView, sales_team).commit();

                    //i.putExtras(bundle);
                    //context.startActivity(i);

                }
            });

        }

        details_sales.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                Intent intent = new Intent(context,
                        Sales.class);
                Bundle bundle = new Bundle();

                bundle.putString("key_username", UserDetails_item.getUserName());
                bundle.putString("key_userid", UserDetails_item.getUserID());
                bundle.putString("report_username", Salesteam.txt_levels.getText().toString());
                bundle.putString("key_FlagList", Flaglist);
                Sales sales_fragment = new Sales();
                sales_fragment.setArguments(bundle);
                FragmentTransaction xfragmentTransaction = fragment.beginTransaction();
                xfragmentTransaction.replace(R.id.containerView, sales_fragment).commit();
                // bundle.putString("report_username", TempUser.getUserName());
                // bundle.putString("report_user_id", TempUser.getUserID());
                intent.putExtras(bundle);
                context.startActivity(intent);
            }
        });

        if (position % 2 == 1) {
            Row.setBackgroundColor(Color.WHITE);

        } else {
            Row.setBackgroundColor(Color.LTGRAY);

        }
        img_count.setAlpha(255);

        txt_item.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);

        return Row;
    }

}
</code></pre>