안드로이드 개발 질문/답변
(글 수 45,052)
<TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
xml파일에 위와 같이 TextView를 정의 했을 경우에는 자바 소스에서
TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText("OK");
으로 해당 위젯에 접근할 수가 있었습니다.
그럼 자바 소스에서 아래와 같이 선언한 후에 레이아웃에 addView를 한 경우에 TextView tv의 값을 바꾸기 위해
접근 하기 위해서는 어떻게 해야 하나요...?
LinearLayout lLayout = (LinearLayout) findViewById(R.id.linearLayout);
TextView tv = new TextView(this);
lLayout.addView(tv);




LinearLayout lLayout = (LinearLayout) findViewById(R.id.linearLayout);
TextView tv = new TextView(this);
lLayout.addView(tv);
tv.setText("OK")
이미 생성해 놓은 tv 가 있잖아요 ^^;;