 |
Listening for UI Notifications [알림 사용자 인터페이스를 위한 대기]
Some UI notifications are automatically exposed and called by Android. For instance, Activity exposes
overrideable methods onKeyDown and onKeyUp, and Widget exposes onFocusChanged(boolean, int).
However, some important callbacks, such as button clicks, are not exposed natively, and must be
registered for manually, as shown here.
몇몇의 알림 사용자 인터페이스는 자동으로 나타나며 안드로이드에 의해 호출된다. 예를 들자면, Activity는
오버라이드 가능한 메쏘드 onKeyDown과 onKeyUp 를, Widget은 onFocusChanged(boolena, int) 를
호출한다. 그렇지만, 몇몇 중요한 콜백들, 버튼 클릭과 같은 것은 기본적으로 호출되지 않는다. 그리고
여기서 보여진 것 처럼 직접 등록해야 한다.
public class SendResult extends Activity { /** * Initialization of the Screen after it is first created. Must at least * call setContentView() to * describe what is to be displayed in the screen. */ protected void onCreate(Bundle savedValues) { ...
// Listen for button clicks. Button button = (Button)findViewById(R.id.corky); button.setOnClickListener(mCorkyListener); }
// Create an anonymous class to act as a button click listener. private OnClickListener mCorkyListener = new OnClickListener() { public void onClick(View v) { // To send a result, simply call setResult() before your // activity is finished. setResult(RESULT_OK, "Corky!"); finish(); } }; |
※ 회원등급 레벨 0 이상 읽기가 가능한 게시판입니다.
16
|