0

我正在尝试在我的程序发生更改时更新我的​​弹出窗口中的文本视图。This displays a popup with the first assigned "firstChar" when an option is chosen. However, when the next option is chosen, it does not update to the new option, just continues showing the original option.

如果我关闭并重新显示弹出窗口,它会闪烁,我不希望这样。每次创建一个新的弹出窗口都会导致内存泄漏。

有任何想法吗?

XML:

<TextView
    android:id="@+id/popupText"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="A"
    android:gravity="center"
    android:textSize="50sp" />

在我的 ListAdapter 中:

LayoutInflater layoutInflater = (LayoutInflater) context
                         .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.toast_custom_layout, null);
TextView popUpText = (TextView) layout.findViewById(R.id.popupText);
popUpText.setText(Character.toString(firstChar));
popUp.setContentView(layout);
popUp.showAtLocation(row, Gravity.CENTER, 0, 0);
popUp.update();
4

1 回答 1

0

如果你像这样订购你的代码?

popUp.setContentView(layout); popUpText.setText(Character.toString(firstChar));

于 2014-02-19T09:07:13.790 回答