안드로이드 개발 질문/답변
(글 수 45,052)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="aaaaa"
/>
<TextView
android:id="@+id/test"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="bbbbb"
/>
</LinearLayout>
xml파일이구요;;
public class aactivity extends Activity {
TextView text;
TextView text1;
int kk;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text = (TextView)findViewById(R.id.text);
text1 = (TextView)findViewById(R.id.test);
String str = this.getResources().getString(R.id.text);
String str1 = this.getResources().getString(R.id.test);
text.setText(str);
text1.setText(str1);
}
java파일인데요.
getstring(int ID)함수가 ID와 관련된 string을 반환하는 함수라고 나와있는데ㅡ
실제로 찍어보면 둘다 false가 나오는데ㅡ
이게 무슨의미인가요??ㅠ
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="aaaaa"
/>
<TextView
android:id="@+id/test"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="bbbbb"
/>
</LinearLayout>
xml파일이구요;;
public class aactivity extends Activity {
TextView text;
TextView text1;
int kk;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text = (TextView)findViewById(R.id.text);
text1 = (TextView)findViewById(R.id.test);
String str = this.getResources().getString(R.id.text);
String str1 = this.getResources().getString(R.id.test);
text.setText(str);
text1.setText(str1);
}
java파일인데요.
getstring(int ID)함수가 ID와 관련된 string을 반환하는 함수라고 나와있는데ㅡ
실제로 찍어보면 둘다 false가 나오는데ㅡ
이게 무슨의미인가요??ㅠ
TextView의 text를 가져오시려면...
text.getText()를 이용하세요.