2

xml から取得したテキストビューがあるとします。

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

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

しかし、複数のtvPopを持ちたいのですが、どのように複製すればよいですか?

ありがとう。

4

1 に答える 1

0

あなたはこれを行うことができます:

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

それが役立つことを願っています。

于 2012-11-29T16:01:02.137 に答える