2

Say I have a textview that I got from xml.

final View popupView = getLayoutInflater().inflate(R.layout.popup, null);  

final TextView tvPop = (TextView)popupView.findViewById(R.id.tvKeyPop);

But I want to have multiple tvPop 's, how should I clone them?

Thanks.

Roger Travis
  • 8,194
  • 17
  • 64
  • 93

1 Answers1

0

you can do this:

TextView cloned = new TextView(getApplicationContext());
cloned.setText(tvPop.getText());
cloned.setLayoutParams(tvPop.getLayoutParams());
...
cloned.setWhateverFieldYouNeedToBeCloned(tvPop().getWhateverFieldYouNeedToBeCloned());

Hope that helps.

Adrián Rodríguez
  • 1,851
  • 14
  • 16