У меня есть некоторый код, который создает всплывающее окно и назначает ему макет XML, в котором есть два элемента ImageView.
popupWindow.setTitle("New note");
popupWindow.setMessage("choose the type of note to create");
View noteChoices = inflater.inflate(R.layout.addnotepopup, null);
popupWindow.setView(noteChoices);
popupWindow.setPositiveButton(null, null);
popupWindow.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//
}
});
popupWindow.show();
В addnotepopup.xml есть два элемента ImageView
Как можноЯ добавляю прослушиватели кликов к этим двум элементам?Когда я пытаюсь сделать это так же, как и любую другую кнопку, findViewById () возвращает нулевое значение
XML-код
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:weightSum="2" >
<ImageView
android:id="@+id/recordnoteoption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:src="@drawable/medium_mic"
android:layout_weight="1" />
<ImageView
android:id="@+id/typenoteoption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:src="@drawable/medium_keyboard"
android:layout_weight="1" />
</LinearLayout>