【发布时间】:2011-09-04 14:47:49
【问题描述】:
我在 Android 中动态更改 TextView 和 PopupWindow 中的文本时遇到问题。我通过使用LayoutInflater 和ViewGroup 在PopupWindow 中引用了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();
}
}
【问题讨论】:
标签: java android textview popupwindow viewgroup