1

我正在尝试获取我创建的 LinearLayout 中的片段:

编辑:这是在扩展的类中ArrayAdapter<G>

LinearLayout newView = new LinearLayout(getContext());
String inflater = Context.LAYOUT_INFLATER_SERVICE;
LayoutInflater li;
li = (LayoutInflater) getContext().getSystemService(inflater);
li.inflate(resource, newView, true);

在布局中有一个名为 TableRowView 的片段:

编辑:我更正了 XML 语法

<fragment android:name ="mypackage.TableRowView"
    android:id="@+id/row"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

如何获取newView's 片段?

在此先感谢,--大卫

4

1 回答 1

2

我正在尝试获取我创建的 LinearLayout 中的片段

片段不在LinearLayout. 片段不是 aView也不驻留在 aViewGroup中。由View片段创建的onCreateView()将驻留在ViewGroup.

我正在尝试获取我创建的 LinearLayout 中的片段

尝试调用findFragmentById()FragmentManager前提是您newView在充气操作之前设置了一个 ID。

于 2013-02-15T18:06:21.883 回答