user3182266
user3182266

Reputation: 1330

Unable to resolve inflate(int)

So I am trying to inflate a layout in my activity but I keep getting this error "Cannot resolve method inflate(int)"

  LayoutInflater layoutInflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View error = layoutInflater.inflate(R.layout.error_internet_connection);

What am I doing wrong?

Upvotes: 4

Views: 8960

Answers (1)

Blackbelt
Blackbelt

Reputation: 157457

there is no method inflate(int). The methods available are inflate(int, ViewGroup) and inflate(int, ViewGroup, boolean).

Change

  View error = layoutInflater.inflate(R.layout.error_internet_connection);

to

 View error = layoutInflater.inflate(R.layout.error_internet_connection, null);

Here you can find the documentation

Upvotes: 10

Related Questions