2011년 10월 30일 일요일

[android] Notepad 예제 중 XML 레이아웃


아래글은

http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html 중
Step 4를 제 기준대로 번역/설명한 내용임

<!--?xml version="1.0" encoding="utf-8"?-->
<linearlayout android="http://schemas.android.com/apk/res/android"
layout_width="wrap_content"
layout_height="wrap_content">

<listview id="@android:id/list"
layout_width="wrap_content"
layout_height="wrap_content">
<textview id="@android:id/empty"
layout_width="wrap_content"
layout_height="wrap_content"
text="@string/no_notes">

</textview>
</listview>
</linearlayout>

  • The ListView and TextView can be thought as two alternative views, only one of which will be displayed at once. ListView will be used when there are notes to be shown, while the TextView (which has a default value of "No Notes Yet!" defined as a string resource in res/values/strings.xml) will be displayed if there aren't any notes to display.
  • (번역) ListView와 TextView는 서로 보완대치된다고 생각하면 된다. 오직 한개의 뷰만 화면에 보여질 뿐이다. ListView는 노트의 값이 있을때 보여지게 되고 만약 한개의 값도 존재하지 않으면 TextView(res/values/strings.xml 파일안에 디폴트 값이 'No Notes Yet'으로 설정되어있음)가 보여지게된다.
  • The list and empty IDs are provided for us by the Android platform, so, we must prefix the id with android: (e.g., @android:id/list).
  • (번역) 리스트와 empty ID들은 안드로이드 플랫폼에 의해 자동으로 제공된다. 그러므로 우리는 반드시 android와 함께 id를 선언해야한다.(예 @android:id/list)
  • The View with the empty id is used automatically when the ListAdapter has no data for the ListView. The ListAdapter knows to look for this name by default. Alternatively, you could change the default empty view by using setEmptyView(View) on the ListView.
  • (번역) empty id가 선언된 뷰는 ListAdapter에 데이터가 없을때 자동으로 사용된다. ListAdapter는 자동으로 찾기 위해 기본적으로 이 이름을 알고 있다.참고로 default empty view는 ListView에서 setEmptyView(View)를 설정함으로 변경할 수 있다
  • More broadly, the android.R class is a set of predefined resources provided for you by the platform, while your project's R class is the set of resources your project has defined. Resources found in the android.R resource class can be used in the XML files by using the android: name space prefix (as we see here).
  • (번역) 흔히 android.R 클래스는 플랫폼에서 기본적으로 제공하는 리소스들을 선언하는 클래스이다. 당신의 프로젝트에서 사용되어지는 R class는 프로젝트에서 정의하는 리소스들의 집합체이다. R 클래스 안에서 보여지는 리소스들은 XML파일 안에서 android:name space prefix(이곳에 보여지는대로) 형태로 정의해서 사용될 수 있다.

댓글 없음: