Questions tagged [android-inflate]

Instantiates a layout XML file into its corresponding View objects

651 questions
382
votes
15 answers

What does LayoutInflater in Android do?

What is the use of LayoutInflater in Android?
user386430
  • 4,837
  • 13
  • 41
  • 45
317
votes
7 answers

What does it mean to inflate a view from an xml file?

I am new to android development and keep coming across references to Inflating views from a layout xml file. I googled and searched the development guide but still wasn't able to pick up a sense for what it means. If someone could provide a very…
Brendan Weinstein
  • 6,938
  • 7
  • 25
  • 29
242
votes
15 answers

How to inflate one view with a layout

I have a layout defined in XML. It contains also: I would like to inflate this RelativeView with other XML layout file. I…
Michal Dymel
  • 4,312
  • 3
  • 23
  • 32
164
votes
33 answers

android.view.InflateException: Binary XML file line #12: Error inflating class

I am receiving many errors of kind displayed in the subj. These errors seems to be occasional and I cannot reproduce them. From stack I can learn that such error may occurs for my different layout resources. The line of XML is also varying. Can…
Solvek
  • 5,158
  • 5
  • 41
  • 64
91
votes
6 answers

Custom Layout for DialogFragment OnCreateView vs. OnCreateDialog

I'm trying to create a DialogFragment using my own Layout. I've seen a couple different approaches. Sometimes the layout is set in OnCreateDialog like this: (I'm using Mono but I've gotten somewhat used to Java) public override Android.App.Dialog…
gghuffer
  • 1,133
  • 1
  • 9
  • 15
84
votes
10 answers

'setHasOptionsMenu(Boolean): Unit' is deprecated. Deprecated in Java

How do I declare a menu inside of Android fragment? The method that I had used previously is now deprecated. Originally: override fun onCreateView(...): View { setHasOptionsMenu(true) } override fun onCreateOptionsMenu(menu: Menu,…
SUR4IDE
  • 1,003
  • 1
  • 5
  • 11
59
votes
2 answers

NPE while inflating layout (Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference)

I keep getting a java.lang.NullPointerException when I try to use ScrollView in an activity. The weird thing is that I've used the exact same Scrollview setup in other activities. And all of a sudden I'm getting errors. I've tried cleaning the…
53
votes
9 answers

Inflate layout programmatically within another layout

I need help with my android app. I need inflate a layout within another layout and I dont know how I do. My xml code is this: item.xml - I need inflate multiple xml (depending on a variable number)
Yeray
  • 1,265
  • 1
  • 11
  • 23
50
votes
9 answers

Problem inflating custom view for AlertDialog in DialogFragment

I'm trying to create a DialogFragment using a custom view in an AlertDialog. This view must be inflated from xml. In my DialogFragment class I have: @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new…
41
votes
3 answers

Plugins architecture for an Android app?

THIS QUESTION HAS MOVED TO https://softwarerecs.stackexchange.com/questions/27841/plugins-architecture-for-an-android-app I want to implement a plugin system for an Open Source app, because it has become really large, with many features that only a…
Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
40
votes
11 answers
40
votes
6 answers

Inflating a xml layout in a custom View class

I have a class View1 that extends View. I want to inflate R.layout.test2.xml in this class View1. I have put a following code in this class public class View1 extends View { View view; String[] countries = new String[] {"India", "USA",…
LuminiousAndroid
  • 1,557
  • 4
  • 18
  • 28
27
votes
4 answers

How to inflate multiple instances of a layout with the same id inside an inflated layout

I have a LinearLayout with many nested LinearLayouts and TextViewss My main activity inflates the main LinearLayout, Then I load data from a server and based on the data received, I add multiple Layouts in a place holder (LinearLayout) This is…
Shehabic
  • 6,787
  • 9
  • 52
  • 93
26
votes
1 answer

inflating fragments with compatibility package android

I am trying to inflate a layout containing a Fragment using the backwards compatibility package. I took the jar file and placed it in the libs folder of my project. I extended Fragment and then tried to inflate it by setting the contentView of the…
19
votes
2 answers

OnMenuItemSelected isn't called when layout is set for menu item

I have a menu which is inflated from main_menu.xml:
1
2 3
43 44