Sorry, this is my first question... I have an ArrayAdapter class and i want to call startActivity from an internal anonymous class, but i'm taking the error "cannot resolve method startActivity"
public View getView(final int position, @Nullable final View convertView, @NonNull ViewGroup parent) {
//inflating the layout
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(R.layout.itemview_antliostasia, parent, false);
//get the reference to the view objects
final TextView myName = (TextView)row.findViewById(R.id.itemViewAntliostasiaName);
final TextView myID = (TextView)row.findViewById(R.id.itemViewAntliostasiaID);
final TextView myAntlies = (TextView)row.findViewById(R.id.itemViewAntliostasiaAntlies);
ImageView myEdit = (ImageView) row.findViewById(R.id.imageAntliostasiaEdit);
ImageView myDelete = (ImageView)row.findViewById(R.id.imageAntliostasiaDelete);
//providing the element of an ArrayList by specifying its position
myName.setText(dataList.get(position).getName());
myID.setText(dataList.get(position).getId());
myAntlies.setText(dataList.get(position).getAntlies());
myEdit.setImageResource(R.drawable.imgedit);
myDelete.setImageResource(R.drawable.imgdelete);
myEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), EditAntliostasioActivity.class);
String[] editValues = new String[2];
editValues[0] = myName.getText().toString();
editValues[1] = myAntlies.getText().toString();
intent.putExtra("edit values", editValues);
startActivity(intent);
}
});
I think something is going wrong with getContext()...Please help me