Android - 在多个 RootView 中获取 Objects

Android - Getting Objects in Multiple RootView

public class OccuMechanical extends android.support.v4.app.Fragment {

    private View v_schedule;
    private LinearLayout layout_schedule;
    private ImageButton iv_add_schedule;

    private int i = 0;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_occu_mechanical, container, false);

        layout_schedule = (LinearLayout) v.findViewById(R.id.layout_mech_schedule);

        iv_add_schedule = (ImageButton) v.findViewById(R.id.iv_add_schedule);
        iv_add_schedule.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                i++;
                v_schedule = LayoutInflater.from(getActivity()).inflate(R.layout.layout_mech_schedule, null);
                layout_schedule.addView(v_schedule);
                EditText et = (EditText) layout_schedule.getRootView().findViewById(R.id.layout_description);
                et.setText("Test: " + String.valueOf(i));
            }
        });
        return v;
    }
}

idk 如果我的术语在标题中是正确的,但这是我正在做的...... 当我单击 'Add more equipment' 时,它会为我的应用添加布局,因此 我想获得我在 RootView 中添加的布局中的所有 EditText, 我尝试设置文本来测试它,但第一个 rootView 的第一个 editText 是唯一的更新。我上面列出的片段中的所有代码。附图是这段代码的结果。

image result

我已经按照 @hjchin 的建议使用 *RecyclerView 完成了这项任务。谢谢!

RecyclerView Tutorial @ Developer.Android