Android > Button - Ŭ¸¯ À̺¥Æ® »ç¿ë¹æ¹ý
µî·ÏÀÏ : 2017-07-06 17:13
Á¶È¸¼ö : 53,054
¸Ç³¯ ±î¸Ô¾î Ã¥ ã¾Æ º¸°í.. ÀÎÅÍ³Ý µÚÁ®º¸°í.. Çؼ ÀÌ ±âȸ¿¡ ¹öÆ°¿¡ ´ëÇÑ Å¬¸¯ À̺¥Æ® Çڵ鷯 Äڵ带 ÀÛ¼ºÇÏ´Â °Í¿¡ ´ëÇØ Á¤¸®¸¦ ÇØ ³ö¾ß°Ú½À´Ï´Ù.
¸Ó¸®°¡ ³ª»Ú´Ï.. ¼ÕÀÌ Á» °í»ýÀ» Çؾ߰ÚÁö¿ä..
·¹À̾ƿô¿¡ µÎ°³ÀÇ ¹öÆ°ÀÌ ÀÖ´Ù°í °¡Á¤ÇÏ°Ú½À´Ï´Ù. id´Â °¢°¢ viewMode, editMode¶ó°í Çϸé. Ŭ¸¯ À̺¥Æ®ÀÇ Äڵ带 ÀÛ¼ºÇÏ´Â ¹æ¹ý¿¡´Â 2°¡Áö°¡ ÀÖ½À´Ï´Ù.
¹°·Ð µûÁ®º¸¸é µÑ´Ù µ¿ÀÏÇÑ ¹æ½ÄÀ̱â´Â ÇÏÁö¸¸ ÄÚµå ¸ð¾ç»õ°¡ ´Ù¸£¹Ç·Î ´Ù¸£´Ù°í Ä¡°Ú½À´Ï´Ù.
ù¹ø° ¹æ½ÄÀÔ´Ï´Ù. ´Ù¼öÀÇ ¹öÆ°µé¿¡ ´ëÇÑ À̺¥Æ® Äڵ带 ÇÑÀÚ¸®¿¡ °¡Á·°°Àº ºÐÀ§±â·Î ´Ù½º¸®´Â ¹æ½ÄÀ̶ó°í ÇÒ ¼ö ÀÖ°Ú½À´Ï´Ù..
@Override
public void onCreate(Bundle savedInstanceState) {
....
findViewById(R.id.viewMode).setOnClickListener(btnClickListener);
findViewById(R.id.editMode).setOnClickListener(btnClickListener);
....
}
private Button.OnClickListener btnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.viewMode:
map.setMouseMode(MouseMode.MapViewMode);
break;
case R.id.editMode:
map.setMouseMode(MouseMode.EditMode);
break;
}
}
};
µÎ¹ø° ¹æ½ÄÀÔ´Ï´Ù. ÀÌ ¹æ½ÄÀº °¢ ¹öÆ°¸¶´Ù À̺¥Æ® ó¸® Äڵ带 µû¶ó ºÐ¸®ÇØ µÎ´Â ¹æ½ÄÀÔ´Ï´Ù.
@Override
public void onCreate(Bundle savedInstanceState) {
....
findViewById(R.id.viewMode).setOnClickListener(
new Button.OnClickListener() {
@Override
public void onClick(View v) {
map.setMouseMode(MouseMode.MapViewMode);
}
}
);
findViewById(R.id.editMode).setOnClickListener(
new Button.OnClickListener() {
@Override
public void onClick(View v) {
map.setMouseMode(MouseMode.EditMode);
}
}
);
....
}
¼¼¹ø° ¹æ¹ýÀº implements ¹æ½ÄÀÔ´Ï´Ù.
public class Member_Login extends Activity implements OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); //ŸÀÌƲ¹Ù ¾ø¾Ö±â
setContentView(R.layout.member_login);
findViewById(R.id.btn_mem_join).setOnClickListener(this); //ȸ¿ø°¡ÀÔ¹öÆ°
findViewById(R.id.btn_mem_login).setOnClickListener(this); //·Î±×ÀιöÆ°
}
public void onClick(View v) {
switch(v.getId())
{
case R.id.btn_mem_join:
//ȸ¿ø°¡ÀÔÆäÀÌÁö·Î À̵¿
break;
case R.id.btn_mem_login:
//·Î±×ÀÎ ¹öÆ° Ŭ¸¯½Ã
break;
}
}
}