문제

I am trying to include a new layout on an event. For that I am using LayoutInflater in That event listener. But the problem is, LayoutInflater.inflate() function expect its parameters to be (Int) ResourceId, ViewGroup. I am unable to figure out what to use as ViewGroup in the event listener. this refers to that event listener. parent and item are both views, not ViewGroups. Please help.

도움이 되었습니까?

해결책

If you're attaching it to your activity, use that. If, however, you want a floating view, make your call as follows:

View view = inflater.inflate(resourceId, null, false);

This will create it and allow you to add it as a view to whatever you please.

다른 팁

Have a look at this article about Layout inflation. It gives a great overview about what params to use in what situations.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top