I have an ListActivity and i am displaying one list with:
setListAdapter(new ArrayAdapter(getApplicationContext(),
android.R.la
If you are creating a class that extends an Adapter, you can use parent variable to obtain the context.
public class MyAdapter extends ArrayAdapter {
private Context context;
@Override
public View getView(int position, View convertView, ViewGroup parent) {
context = parent.getContext();
context.getResources().getColor(R.color.red);
return convertView;
}
}
You can do the same with RecyclerView.Adapter, but instead of getview() you will use onCreateViewHolder().