У меня есть код для разметки раздувания:
mainLayout = findViewById(R.id.mainLayout);
addNewMed.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addNewMed.startAnimation(AnimationUtils.loadAnimation(MedicationAdd.this, R.anim.rotate_complete));
v = LayoutInflater.from(MedicationAdd.this).inflate(R.layout.medication_poles, null);
mesurement = v.findViewById(R.id.mesurement);
mainLayout.addView(v);
}
});
И когда я хотел бы найти свой счетчик mesurement
из medication_poles
, у меня есть нулевая ошибка
medication_poles.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/medPole"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginBottom="8dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Время приема"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Препарат"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Дозировка"/>
<Spinner
android:id="@+id/mesurement"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Spinner>
</LinearLayout>
Как найти объект из раздуваемого макета?