Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getIntent error, doesnt get recognized

Tags:

android

getIntent does not get recognized, what I am doing wrong?

I get this error:

error: cannot find symbol variable getIntent

PS: at first I got this error cannot find symbol method getIntent.

My code:

package com.example.r.app;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;


public class MyAdapter extends ArrayAdapter<String> {

    int i=0;

    public MyAdapter(Context context, int resource, List<String> objects) {
        super(context, resource, objects);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = super.getView(position, convertView, parent);
        TextView textView = (TextView) view.findViewById(android.R.id.text1);

        Intent intent = getIntent;
        int[] barva = intent.getIntArrayExtra("barva");

        int[] bar = {1, 2, 3};

        if (position == i) {
            if (barva == bar){
                textView.setTextColor(0xffcc80);
            }
            else if (barva == bar){
                textView.setTextColor(0xa5d6a7);
            }
            else if (barva == bar){
                textView.setTextColor(0x80deea);
            }

        }
         return view;
    }

}
like image 786
Everlastinf Avatar asked Apr 26 '26 20:04

Everlastinf


1 Answers

error: cannot find symbol variable getIntent

First,getIntent is method instead of variable so call it as:

Intent intent = getIntent();

Second, getIntent() method is from Activity class instead of ArrayAdapter class so this method is not available in class which is extending ArrayAdapter.

Call getIntent() method from Activity in which creating object of MyAdapter and pass intent as parameter to constructor.

like image 74
ρяσѕρєя K Avatar answered Apr 29 '26 10:04

ρяσѕρєя K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!