<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);