부모 컨테이너를 동적으로 채우는 응용 프로그램을 개발 중입니다 LinearLayout
다른 많은 LinearLayout
자식이 있고 각 자식은 많은 ImageButton
으로 채워지므로 기본적으로 다음과 같습니다.
안드로이드 - ImageButton onClick 이벤트가 실행되지 않습니다.
<ScrollView
android:layout_height="match_parent"
android:layout_width="fill_parent">
<LinearLayout
android:id="@+id/phasesContainer" (parent container)
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
그리고 자바 코드 :
XML 코드는
for (PhaseActor pa : ph.get_actors()) {
if (pa.get_prospective() != Phase.PROGRAM)
continue;
ImageView phaseActor = new ImageView(context);
phaseActor.setImageResource((int) getActorFromMemory(
pa.get_actroId()).get_iconId());
phaseActor.setMaxHeight(30);
phaseActor.setMaxWidth(30);
phaseActor.setTag(pa.get_id());
phaseActor.setBackgroundResource(android.R.color.transparent);
phaseActor.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
editPhaseActorClick(Integer.getInteger(v.getTag()
.toString()));
}
});
// This container is the child (LinearOut) container
container.addView(phaseActor, imageLayout); }
ImageView를 클릭하면 아무 것도하지 않습니다 .. 기능이 실행되지 않습니다!