public class MainFragment extends Fragment implements MapView.CurrentLocationEventListener, View.OnClickListener {
...
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
...
// Fragment에서는 onClick을 사용할 수 없기때문에, 별도로 리스너를 달아서 클릭이벤트를 지정한다.
ImageButton btn = v.findViewById(R.id.btn);
Button btn_in = v.findViewById(R.id.btn_in);
Button btn_out = v.findViewById(R.id.btn_out);
Button btn_exOut = v.findViewById(R.id.btn_exOut);
btn.setOnClickListener(this);
btn_in.setOnClickListener(this);
btn_exOut.setOnClickListener(this);
btn_out.setOnClickListener(this);
...
}
// 버튼 클릭 이벤트 리스너
@Override
public void onClick(View view) {
switch (view.getId()){
//출근버튼
case R.id.btn_in:
//출근 관련 로직
Toast.makeText(getContext(),"출근 완료",Toast.LENGTH_SHORT).show();
break;
//퇴근 버튼
case R.id.btn_out:
//퇴근 관련 로직
Toast.makeText(getContext(),"퇴근 완료",Toast.LENGTH_SHORT).show();
break;
//예외 퇴근 버튼
case R.id.btn_exOut:
// 예외 퇴근 관련 로직
Toast.makeText(getContext(),"예외 퇴근 완료",Toast.LENGTH_SHORT).show();
break;
// 우측 상단 현위치+범위표시 이미지버튼
case R.id.btn:
mapView.setShowCurrentLocationMarker(true);
mapView.setCurrentLocationRadius(100);
mapView.setZoomLevel(1,true);
break;
}
}
}