getLayoutInflater() does not exist
Hi,
thanks for the awesome lib. I've tried to reproduce your code, and just noticed that getLayoutInflater() is not a method from BaseAdapter nor CardStackAdapter.
Instead, I had to obtain the LayoutInflater from the Context, so another parameter of type Context is needed in the constructor.
If you want, I can provide you a pull request updating the documentation, and also the code if you're interested.
Keep up the good work!
Have found the exact problem that you are writing about but I've not been able to solve it. I would, therefore, appreciate if you could describe your solution a bit more. Thanks in before!
Yes sorry, my explaination was lacking details. I tried to copy this code you provide in the README file
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.card, parent, false);
TextView textViewCard = (TextView) convertView.findViewById(R.id.textViewCard);
textViewCard.setText(mData.get(position));
return convertView;
}
Then found that compiler marked me getLayoutInflater() in red. This method does not exist in my CardStackAdapter class. I solved it by passing a Context argument:
class CardStackAdapter(val context: Context, val otherArgs : SomeOtherArguments....) : BaseAdapter() {
and obtain the LayoutInflater like this
val inflater = context.getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater
So my issue was that there is no way of obtaining the LayoutInflater in the example code