Как из класса ArrayAdapter по нажатию на кнопку перейти на другой Activity?

есть ProductAdapter. в котором надо сделать переход на MapsActivity.class. код:

class ProductAdapter extends ArrayAdapter<Product> {
    private LayoutInflater inflater;
    private int layout;
    private ArrayList<Product> productList;
    Intent intent_maps;

    ProductAdapter(Context context, int resource, ArrayList<Product> products) {
        super(context, resource, products);
        this.productList = products;
        this.layout = resource;
        this.inflater = LayoutInflater.from(context);
    }
    public View getView(int position, View convertView, ViewGroup parent) {

        final ViewHolder viewHolder;
        if(convertView==null){
            convertView = inflater.inflate(this.layout, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }
        else{
            viewHolder = (ViewHolder) convertView.getTag();
        }
        final Product product = productList.get(position);

        viewHolder.nameView.setText(product.getName());
        viewHolder.yearView.setText(product.getYear());
        viewHolder.sizeView.setText(product.getSize());
        viewHolder.removeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {//здесь идет переход 
             //   Intent Fragment1 = new Intent(ProductAdapter.this, MainActivity.class); не работает
               // startActivity(Fragment1);


                /*Intent intent_list = new Intent(getContext(), MapsActivity.class);
                startActivity(getContext(), intent_list);
                //Intent intent = new Intent(getContext(), MapsActivity.class);
                //getContext().startActivity(intent);

               // productList.get(1);
               /* int count = product.getCount()-1;
                if(count<0) count=0;
                product.setCount(count);
                viewHolder.sizeView.setText(count + " " + product.getUnit());*/
            }
        });
        viewHolder.addButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
             /*   int count = product.getCount()+1;
                product.setCount(count);
                viewHolder.yearView.setText(count + " " + product.getUnit());*/
            }
        });

        return convertView;
    }
    private class ViewHolder {
        final Button addButton, removeButton;
        final TextView nameView, yearView,sizeView;
        ViewHolder(View view){
            addButton = (Button) view.findViewById(R.id.infoButton);
            removeButton = (Button) view.findViewById(R.id.lookButton);
            nameView = (TextView) view.findViewById(R.id.nameView);
            yearView = (TextView) view.findViewById(R.id.yearView);
            sizeView = (TextView) view.findViewById(R.id.sizeView);
        }
    }
}

есть ListActivity. который генерирует нужное количество компонентов на форме. в нем я принимаю некоторую информацию и потом строю компоненты с этой информацией. ну текст им задаю. код:

public class ListActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_activity);

        //прием
        Intent intent = getIntent();
        Bundle args = intent.getBundleExtra("BUNDLE");
        ArrayList<Object> object = (ArrayList<Object>) args.getSerializable("ARRAYLIST");

        //прием

        ArrayList<Product> products = new ArrayList<Product>();
        int i=0;
        if(products.size()==0)
        while(i<17){
            products.add(new Product(object.get(i+2).toString(),object.get(i+7).toString(),object.get(i+5).toString()));
            i+=8;
        }


        /*if(products.size()==0){
            products.add(new Product("Имя","год","размер"));
            products.add(new Product("Имя2","год2","размер2"));
            products.add(new Product("Имя3","год3","размер3"));
        }*/

        ListView productList = (ListView) findViewById(R.id.productList);
        ProductAdapter adapter = new ProductAdapter(this, R.layout.list_item, products);
        productList.setAdapter(adapter);



    }

    }

я так понимаю нельзя просто так взять и в

viewHolder.removeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) 

написать Intent Fragment1 = new Intent(ProductAdapter.this, MapsActivity.class); startActivity(Fragment1);

пишет - Cannot resolve constructor Intent(com.example.animation1.ProductAdapter, java.lang.Class<com.example.animation1.MapsActivity>)

код MainActivity:

public class MainActivity extends AppCompatActivity {

    TextView tv;
    LinearLayout lr1;
    InputStream inputStream;
    String[] ids;
    ArrayList<String> ar = new ArrayList<String>();
    List<ArrayList<String>> a = new ArrayList<>();
    ArrayList<String> temp = new ArrayList<String>();
    Intent intent_list,intent_list2;
    Intent intent_maps;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        int i=0;
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv=(TextView)findViewById(R.id.textView);
        lr1=(LinearLayout)findViewById(R.id.linerl1);

        ArrayList<Product> products = new ArrayList<Product>();

        inputStream = getResources().openRawResource(R.raw.bridge_spb_rus_test);
        BufferedReader reader=new BufferedReader(new InputStreamReader(inputStream, Charset.forName("windows-1251")));
        try{
            String csvLine;
            while ((csvLine=reader.readLine())!=null){
                ids=csvLine.split(";");
                for (int i2=0;i2<=7;i2++) {
                    ar.add(ids[i2]);
                    a.add(ar);
                }
                try {
                    //  textView.setText(ar[1]);
                }catch (Exception e){
                    Log.e("error",e.toString());
                }
            }
        }catch (IOException ex){
            throw new RuntimeException("error IO"+ex);
        }

       /* if(products.size()==0){//меняю тут!!!!
            i=0;
            for(ArrayList obj:a){
                temp = obj;
                for(String job : temp){
                    data2.add(job);
                    i++;
                    // products.add(new Product(job,temp.get(0)));
                }
            }*/
        if(products.size()==0){//меняю тут!!!!
            for(ArrayList obj:a)
                temp = obj;
            intent_list = new Intent(MainActivity.this, ListActivity.class);
            intent_list2 = new Intent(MainActivity.this, ProductAdapter.class);
            intent_maps=new Intent(MainActivity.this, MapsActivity.class);
            Bundle args = new Bundle();
            args.putSerializable("ARRAYLIST",(Serializable)temp);
            intent_list.putExtra("BUNDLE",args);
            intent_list2.putExtra("BUNDLE",args);
            intent_maps.putExtra("maps",args);


        }


    }
    public void Onclick_menu (View v){
        if (lr1.getVisibility()==View.GONE)
        {
            lr1.setVisibility(View.VISIBLE);
            lr1.startAnimation(AnimationUtils.loadAnimation(this,R.anim.list_up));
        }
        else {

                lr1.setVisibility(View.GONE);
                lr1.startAnimation(AnimationUtils.loadAnimation(this,R.anim.list_down));
        }

    }
    public void Onclick_maps (View v){

        startActivity(intent_maps);
    }
    public void Onclick_list (View v){
        startActivity(intent_list);
    }
}

тут я переда ListActivity список. надо мне теперь этот список получить в ProductAdapter и передать в MapsActivity. только в ProductAdapter нельзя написать:

Intent  intent = getIntent();
                Bundle args = intent.getBundleExtra("BUNDLE");
                ArrayList<Object> object = (ArrayList<Object>) args.getSerializable("ARRAYLIST");

на строку Intent intent = getIntent(); ругается. пишет Cannot resolve method 'getIntent()'.

пакеты import android.content.Intent; есть.

после нажатия на динамически созданную кнопку -> RUN:

I/zzca: Making Creator dynamically
W/zygote: Unsupported class loader
W/zygote: Skipping duplicate class check due to unsupported classloader
I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:203114000
    Selected remote version of com.google.android.gms.maps_dynamite, version >= 203114000
V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
W/ResourceType: ResTable_typeSpec entry count inconsistent: given 62, previously 64
W/zygote: Unsupported class loader
W/zygote: Skipping duplicate class check due to unsupported classloader
I/Google Maps Android API: Google Play services client version: 12451000
I/Google Maps Android API: Google Play services package version: 213314068
I/Google Maps Android API: Google Play services maps renderer version(legacy): 203114000
I/zygote: Do full code cache collection, code=126KB, data=112KB
    After code cache collection, code=125KB, data=68KB
I/zygote: Do partial code cache collection, code=125KB, data=70KB
I/zygote: After code cache collection, code=125KB, data=70KB
    Increasing code cache capacity to 512KB
I/Choreographer: Skipped 59 frames!  The application may be doing too much work on its main thread.
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [540x960]-format:1
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.animation1, PID: 18600
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.Serializable android.os.Bundle.getSerializable(java.lang.String)' on a null object reference
        at com.example.animation1.MapsActivity.onMapReady(MapsActivity.java:51)
        at com.google.android.gms.maps.zzat.zzb(com.google.android.gms:play-services-maps@@17.0.1:1)
        at com.google.android.gms.maps.internal.zzaq.zza(com.google.android.gms:play-services-maps@@17.0.1:6)
        at com.google.android.gms.internal.maps.zzb.onTransact(com.google.android.gms:play-services-maps@@17.0.1:3)
        at android.os.Binder.transact(Binder.java:627)
        at eb.aZ(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (110304-0):2)
        at com.google.maps.api.android.lib6.impl.bk.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (110304-0):1)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6543)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
I/bf: Successfully registered with Phenotype.
E/Google Maps Android API: Authorization failure.  Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
    Ensure that the "Google Maps Android API v2" is enabled.
    Ensure that the following Android Key exists:
        API Key: AIzaSyBN-(скрыл)
        Android Application (<cert_fingerprint>;<package_name>): 61:9F:CB:9B:C9:1D:7C:ED:CD:6E:7B:38:A9:A6:66:59:A9:05:B4:C9;com.example.animation1
W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:6
    Selected remote version of com.google.android.gms.googlecertificates, version >= 6
W/zygote: Unsupported class loader
W/zygote: Skipping duplicate class check due to unsupported classloader

DEBUG:

I/zzca: Making Creator dynamically
W/zygote: Unsupported class loader
W/zygote: Skipping duplicate class check due to unsupported classloader
I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:203114000
    Selected remote version of com.google.android.gms.maps_dynamite, version >= 203114000
V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
W/ResourceType: ResTable_typeSpec entry count inconsistent: given 62, previously 64
W/zygote: Unsupported class loader
W/zygote: Skipping duplicate class check due to unsupported classloader
I/Google Maps Android API: Google Play services client version: 12451000
W/ProtoDataStoreFlagStore: Unable to retrieve flag snapshot for com.google.android.gms.maps#com.example.animation1, using defaults.
I/Google Maps Android API: Google Play services package version: 213314068
I/Google Maps Android API: Google Play services maps renderer version(legacy): 203114000
I/zygote: Do full code cache collection, code=126KB, data=113KB
I/zygote: After code cache collection, code=125KB, data=70KB
I/zygote: Do partial code cache collection, code=125KB, data=75KB
    After code cache collection, code=125KB, data=75KB
    Increasing code cache capacity to 512KB
I/Choreographer: Skipped 63 frames!  The application may be doing too much work on its main thread.
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [540x960]-format:1
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.animation1, PID: 18293
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.Serializable android.os.Bundle.getSerializable(java.lang.String)' on a null object reference
        at com.example.animation1.MapsActivity.onMapReady(MapsActivity.java:51)
        at com.google.android.gms.maps.zzat.zzb(com.google.android.gms:play-services-maps@@17.0.1:1)
        at com.google.android.gms.maps.internal.zzaq.zza(com.google.android.gms:play-services-maps@@17.0.1:6)
        at com.google.android.gms.internal.maps.zzb.onTransact(com.google.android.gms:play-services-maps@@17.0.1:3)
        at android.os.Binder.transact(Binder.java:627)
        at eb.aZ(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (110304-0):2)
        at com.google.maps.api.android.lib6.impl.bk.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (110304-0):1)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6543)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
I/bf: Successfully registered with Phenotype.
E/Google Maps Android API: Authorization failure.  Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
    Ensure that the "Google Maps Android API v2" is enabled.
    Ensure that the following Android Key exists:
        API Key: AIzaSyBN-(СКРЫЛ)
        Android Application (<cert_fingerprint>;<package_name>): 61:9F:CB:9B:C9:1D:7C:ED:CD:6E:7B:38:A9:A6:66:59:A9:05:B4:C9;com.example.animation1
W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:6
    Selected remote version of com.google.android.gms.googlecertificates, version >= 6
W/zygote: Unsupported class loader
W/zygote: Skipping duplicate class check due to unsupported classloader
Disconnected from the target VM, address: 'localhost:49861', transport: 'socket'

Ответы (0 шт):