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,402
  • 18
  • 67
  • 94

1 Answers1

1

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,836
  • 15
  • 16