说我有一个我从xml获得的textview。
final View popupView = getLayoutInflater().inflate(R.layout.popup, null);
final TextView tvPop = (TextView)popupView.findViewById(R.id.tvKeyPop);
但我希望有多个 tvPop ,我应该如何克隆它们?
感谢。
答案 0 :(得分:0)
你可以这样做:
TextView cloned = new TextView(getApplicationContext());
cloned.setText(tvPop.getText());
cloned.setLayoutParams(tvPop.getLayoutParams());
...
cloned.setWhateverFieldYouNeedToBeCloned(tvPop().getWhateverFieldYouNeedToBeCloned());
希望有所帮助。