LoginSignup
49
54

More than 5 years have passed since last update.

Androidの開発で迷った時に見るブログの記事

Last updated at Posted at 2016-05-18

LayoutInflatter.inflater の第2パラメータと、第3パラーメータについて

public View inflate (int resource, ViewGroup root, boolean attachToRoot)

第2引数は、 作成したViewをaddする予定の ViewGroup, 第3引数は、inflate した時点で root に addView するかどうか。
mRootLayout というメンバーを持っていたとして、下記6パターンある

  1. inflate(R.layout.hoge, mRootLayout, true)
    返り値の View は、mRootLayout
    基本的にはこのメソッドを使用して、View を inflate する。

  2. inflate(R.layout.hoge, mRootLayout, false)
    返り値の View は、R.layout.hoge の root
    mRootViewに のちに addView が必要。RecycleView などで、View を Attach する予定の ViewGroup を指定して、 View を作る必要があるが、View を作成した時に、View を root に Attach したくない場合に使用する.

  3. inflate(R.layout.hoge, null, true)

  4. inflate(R.layout.hoge, null, false)
    返り値の View は、R.layout.hoge の root
    View を Add するときに、LayoutParam の調整が効かず、xml に指定した Layout 情報が無視される。
    Warning もでるので基本的に使用しない。
    attachToRoot が true なのに、root が nullなので意味がない?

  5. inflate(R.layout.hoge, null)
    inflate (int resource, ViewGroup root) は、内部で、inflate (resource, root, root != null ) を呼んでいるので、
    4 と同じ

  6. inflate(R.layout.hoge, mRootLayout)
    inflate (int resource, ViewGroup root) は、内部で、inflate (resource, root, root != null ) を呼んでいるので、
    1 と同じ

ActionBar/ToolBar の Up と BackKey の Back をどのように実装するか迷ったら

Android Up の振る舞いパターンを実装する

ActionBar/ToolBar のカスタマイズで迷ったら

Toolbarをカスタマイズする際にどこをいじればよいのか
AndroidのToolBar(新しいActionBar)メモ
[Android]5.0Lollipopで追加されたToolbarでカスタム実装(戻るボタン・検索ボタンを追加)するところまで
ActionBar の withText で文字がでる条件はどこで決まる?

Fragmentのコツとか

【Android】Fragmentを使うときのコツとか色々
AndroidStudioの標準デザインパターンで分かるFragment入門
ActionBar の withText で文字がでる条件はどこで決まる?

Fragment add/remove/replace ってどう使う?

Android FragmentTransaction のまとめ

CoordinatorLayoutってなんだろ。ウニョウニョ出たり入ったりしてよくわからんって時は...

AndroidのCoordinatorLayoutを使いこなして、モダンなスクロールを実装しよう

Resource の文字列で String.format 的な引数入れたいとか,改行とかどうするんだっけとか

複雑な文字列をリソースで定義する

RecyclerView関連

RecyclerView vs ListView

Master of RecyclerView

RecyclerView に divider (セルの区切り線)をつけたい

RecyclerViewで行間に区切り線を表示する

49
54
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
49
54