2nd year Pokemon trainer SE android application development summary ~ 1st day ~

Introduction

Actually, I wanted to write it as a series of "** Programming that can be understood even in F-run humanities **".

  1. The energy spent per article is unusual
  2. I thought it was more meaningful to write an article by researching for development than to research for writing an article
  3. What I realized that it wouldn't continue unless it was a little bit

For the above three reasons, I would like to write an article in the new series "** 2nd year Pokemon trainer SE android application development summary **" series from today.

I would like to summarize what I learned for the first time in advancing the Instagram Clone App at the URL below, and what I stumbled upon. https://www.youtube.com/channel/UCoNZZLhPuuRteu02rh7bzsw In addition, about 40 parts have already been advanced.

LayoutInflater class

Used to instantiate an xml file into the corresponding View object. Inflating is to read the xml file that describes the layout and read it. It means creating the corresponding actual object and visualizing the object within the android app.

Reference: https://code.i-harness.com/ja/q/350fae

Use LayoutInflater # inflate () when generating a View from an xml file. The pattern and explanation of function calls are as follows.

1. inflate(int resource, ViewGroup root)
   Inflate a new view hierarchy from the specified xml resource.

2. inflate(XmlPullParser parser, ViewGroup root)
   Inflate a new view hierarchy from the specified xml node.

3. inflate(XmlPullParser parser, ViewGroup root, boolean attachToRoot)
   Inflate a new view hierarchy from the specified XML node.

4. inflate(int resource, ViewGroup root, boolean attachToRoot)
   Inflate a new view hierarchy from the specified xml resource.

After investigating, "a mechanism that can use the specified xml layout (View) resource" is the most suitable. It seems to be used to convert xml to View and display it.

Is the word "Inflate" quite popular in this industry? ~~ I thought it was an android-specific class, but it was a java standard class, so it seems better to remember. ~~ It was an android specific class. .. .. Click here for reference. https://developer.android.com/reference/android/view/LayoutInflater By the way, this is what I was looking at. http://cr.openjdk.java.net/~iris/se/11/latestSpec/api/java.base/java/util/zip/Inflater.html I found that Inflater itself exists elsewhere, so the result is okay.

By the way, the code I'm using looks like this.

public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dialog_confirm_password, container,false);
    mPassword = view.findViewById(R.id.confirm_password);

    TextView confirmDialog = (TextView) view.findViewById(R.id.dialogConfirm);
    -------The following is omitted-------

This time, when displaying the dialog for password input from another screen, pass inflater and use it to get the view of the dialog.

LayoutInflater#inflate Provides a way to transform the res / layout / *. Xml file that defines the view into the actual View object that can be used in the application source code. It seems that this function actually makes the layout an object.

View class

The View class is a class that has the functions that form the basis of the view. The view class inherits this class. Reference: https://mitoroid.com/category/android/android_view_class.php

Various widgets (TextView and ImageView) placed in the layout come in. It seems that it is often used as a saucer in super class.

Summary

Today about ** Layout Inflater ** and ** View **. From now on, I will improve the quality of the article little by little. Thank you for your hard work.

Recommended Posts

2nd year Pokemon trainer SE android application development summary ~ 1st day ~
2nd year Pokemon trainer SE android application development summary ~ 2nd day ~
Android development link summary
Android application development preparation 7/15
Introduction to Android application development
Web application development article summary
Notes for Android application development beginners