I have a method that would receive the context and the List so it could change the background color of the adapter and return it, but now I have a situation that it must be either a android.R.Layout.simple_list_item_1
for single line and android.R.Layout.simple_list_item_2
or it could be any other type of android.R.Layout.*
How I can define the param on the method?
This is the method that I have for the moment
private ArrayAdapter<String> AdapterColor(List<String> list, Context context)
{
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list)
{
@Override
public View getView(int position, View converView, ViewGroup parent)
{
View view = super.getView(position, converView, parent);
if(position %2 == 1)
{
view.setBackgroundColor(Color.parseColor("#FFD6D6D6"));
}
else
{
view.setBackgroundColor(Color.parseColor("#FFFAFAFA"));
}
return view;
}
};
return adapter;
}
I did try the Layout as param but doesn't work, I did search it but can't find info about this.
Edit
I wanted to do something like this:
private ArrayAdapter<String> AdapterColor(List<String> list, Context context, Layout layoutParam)
{
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, layoutParam, list)
{
@Override
public View getView(int position, View converView, ViewGroup parent)
{
View view = super.getView(position, converView, parent);
if(position %2 == 1)
{
view.setBackgroundColor(Color.parseColor("#FFD6D6D6"));
}
else
{
view.setBackgroundColor(Color.parseColor("#FFFAFAFA"));
}
return view;
}
};
return adapter;
}
Wanted to receive the LayoutParam
from outside to the method, making the code more easy.