假设我有一个从 xml 获得的文本视图。
final View popupView = getLayoutInflater().inflate(R.layout.popup, null);
final TextView tvPop = (TextView)popupView.findViewById(R.id.tvKeyPop);
但我想要多个tvPop的,我应该如何克隆它们?
Thanks.
你可以这样做:
TextView cloned = new TextView(getApplicationContext());
cloned.setText(tvPop.getText());
cloned.setLayoutParams(tvPop.getLayoutParams());
...
cloned.setWhateverFieldYouNeedToBeCloned(tvPop().getWhateverFieldYouNeedToBeCloned());
希望有帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)