I have an adapter, I want to inflate a view but I can't.
This is my class code:
private static class RandomsAdapter extends BaseAdapter{
private Randoms randoms;
private RandomsAdapter(Randoms randoms) {
this.randoms=randoms;
}
public void updateRandoms(Randoms randoms) {
this.randoms=randoms;
notifyDataSetChanged();
}
@Override
public int getCount() {
return randoms.size();
}
@Override
public Random getItem(int position) {
return randoms.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
public View getView(int position,View convertView,ViewGroup parent) {
View view=convertView;
if (convertView == null) {
convertView=getLayoutInflater().inflate(R.layout.random_bars,parent,false);
}
}
}
I am getting an error for this line: convertView=getLayoutInflater().inflate(R.layout.random_bars,parent,false);
Error: Cannot make a static reference to the non-static method getLayoutInflater() from the type Activity
How can I resolve it?