Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

getLayoutInflater() does not exist #50

Open
voghDev opened this issue Aug 30, 2017 · 2 comments
Open

getLayoutInflater() does not exist #50

voghDev opened this issue Aug 30, 2017 · 2 comments

Comments

@voghDev
Copy link

voghDev commented Aug 30, 2017

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!

@Sanjot01
Copy link

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!

@voghDev
Copy link
Author

voghDev commented Oct 27, 2017

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants