我正在开发一个应用程序,在该应用程序中,我动态地填充了LinearLayout
许多其他LinearLayout
子容器的父容器,并且这些子容器中的每一个都被填充了很多ImageButton
,基本上是这样的:
XML 代码是:
<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>
和Java代码:
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 时,它什么也不做......该功能不会被触发!