메소드와 메소드를 도트 연산자로 연결하면...
package com.APP03_STRING;
import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;
public class APP03_STRING extends Activity {
/** Called when the activity is first created. */
TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView)findViewById(R.id.text01);
String rStr1 = getResources().getString(R.string.messages); // getResources() 와 getString() 를 도트 연산자로 연결을 했는데
// 어떻게 이해를 해야할지 결과는 어떻게 나올지를 모르겠습니다.
// 왕초보라 힘드네요^^
String rStr2 = String.format(rStr1,100,"최고");
String escStr = TextUtils.htmlEncode("<i> 최고 </i>");
String rStr3 = String.format(rStr1, 100, escStr);
tv.setText(rStr2 + "\n\n <i> 최고 </i>를 htmlEncode형식으로 표현하면 \n\n " + rStr3);
}
}
// 공지사항 다 읽었음...
String rStr1 = getResources().getString(R.string.messages);
이 코드는 프로젝트 res -> values -> strings.xml에 등록된 문자열을 가져오는 코드 입니다.
이 코드는 다음과 같이 분리 됩니다.
Resources androidResources = getResources(); //리소스 객체 얻어옴.
String rStr1 = andoridResources.getString(R.string.messages); //리소스에 등록된 문자열을 가져온다
각 메소드의 반환형을 보시면 됩니다. getResources() 메소드를 통해서 Resources 객체가 반환되어 옵니다.
getString()은 반환 되어 온 Resources 객체의 메소드가 됩니다.
getString()은 결국 String형을 반환하므로 String 객체인 rStr1로 받게 되는 것입니다.




getResources()를 호출하면 Resources 객체를 반환합니다.
getResources().getString(R.string.messages); 이 구문은
Resources객체.getString(R.string.messages);라고 볼수 있죠.
반환된 객체에대한 함수를 호출하신다고 생각하시면 됩니다.