2
我在動態更改TextView
中的PopupWindow
中的文本時出現問題。我通過使用LayoutInflater
和ViewGroup
引用PopupWindow
中的TextView
元素,但文本未更新。任何幫助將非常感謝! :)在PopupWindow中更改TextView的TextView不起作用
我的代碼如下:
private void popupWindow() {
try {
LayoutInflater inflater = (LayoutInflater) SwingSpeed.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.popup_recording,
(ViewGroup) findViewById(R.id.popup_element));
pw = new PopupWindow(inflater.inflate(R.layout.popup_recording,
null, false), 480, 800, true);
pw.showAtLocation(findViewById(R.id.swingspeed), Gravity.CENTER, 0,
0);
recording_text = (TextView) layout
.findViewById(R.id.recording_text);
recording_text.setText("Recording"); //Update the TextView
} catch (Exception e) {
e.printStackTrace();
}
}
非常好,工作!非常感謝!! – BGM