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;
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With