facebook twitter hatena line email

Android/レイアウト/レイアウトファイルをjavaで取得

提供: 初心者エンジニアの簡易メモ
2019年3月26日 (火) 16:30時点におけるAdmin (トーク | 投稿記録)による版 (ページの作成:「res/layout/video_item.xml <pre> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height...」)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

res/layout/video_item.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/iconImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

hogehoge.java

import android.view.LayoutInflater;
LayoutInflater inflater = LayoutInflater.from(this);
LinearLayout itemLayout = (LinearLayout)inflater.inflate(R.layout.video_item, null);

参考:http://inujirushi123.blog.fc2.com/blog-entry-27.html

参考:https://developer.android.com/reference/android/view/LayoutInflater