【发布时间】:2013-12-14 14:49:36
【问题描述】:
我有这个片段类:
import iumingv.android.physicalcontribution.R;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FragmentDispositivi extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_dispositivi, container, false);
return rootView;
}
还有这个 xml 布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#fa6a6a" >
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Dispositivi"
android:textSize="20dp"
android:layout_centerInParent="true"/>
</RelativeLayout>
如果我想从一个 ArrayList 中添加多个 TextView 到下面 Fragment 的布局中,我该怎么做?
【问题讨论】:
-
如果我理解正确,您想以编程方式将 TextViews 添加到该布局中吗?
标签: android android-layout arraylist android-fragments