0

プログラムで変更が発生したときに、ポップアップ ウィンドウでテキストビューを更新しようとしています。オプションを選択すると、最初に割り当てられた「firstChar」がポップアップに表示されます。ただし、次のオプションが選択されると、新しいオプションに更新されず、元のオプションが引き続き表示されます。

ポップアップを閉じて再表示すると、ちらつきますが、それは望ましくありません。毎回新しいポップアップ ウィンドウを作成すると、メモリ リークが発生します。

何か案は?

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 に答える