What is the function of setcontentview and inflatter in Android Studio?

Android Studio reference by Google

setContentView(View) is a method exclusively available for Activity.

Internally it calls the setContentView(View) of Window. This method sets the activity content to an explicit view.

SetContentView() method is 3 types.

  1. setContentView(int resourceId)
  2. setContentView(View view)
  3. setContentView(View view, android.view.ViewGroup.layoutparams params)

This view is placed directly into the activity’s view hierarchy. Calling this function “locks in” various characteristics of the window that can not, from this point forward, be changed. Hence it is called only once.

LayoutInflater is used to instantiate layout XML file into its corresponding View objects.

reference: google.com

public abstract class LayoutInflater
extends Object

java.lang.Object ↳android.view.LayoutInflater

Basically the purpose is to create view objects at runtime depending on the requirement.

Best example is the AdapterViews like ListView, Spinner etc, where a single view object corresponding to single record is created at run time depending on the number of records.

Learn more here LayoutInflater:https://developer.android.com/reference/android/view/LayoutInflater

If you have more questions regarding android app development services then contact to our Hire dedicated Android developers now.

--

--

--

Web & Mobile App Development Company. Expertise in Mobile App,PHP, ASP.NET, MVC 5 (Razor),MongoDB, NodeJS, AngularJS, ReactJS,Windows App, POS, Scraping.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Android Startup

Using Glide ? Few tips to be a pro

Making Custom Views on Android Accessible

Deal with Android Studio

Button Click Me setOnClickListener Method Working— Java Android

Get user input in an app: Part 1

View binding : Android

2 articles & Gift recommendation from Kt. Academy 🔥

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rlogical Techsoft.Pvt.Ltd

Rlogical Techsoft.Pvt.Ltd

Web & Mobile App Development Company. Expertise in Mobile App,PHP, ASP.NET, MVC 5 (Razor),MongoDB, NodeJS, AngularJS, ReactJS,Windows App, POS, Scraping.

More from Medium

Razorpay integration android — kotlin

How to make a simple Countdown Timer in Android

Android: Handle typing status in a chat app

Android — Repeat notification daily on specific time