Page 983 - 3-3
P. 983
EditText txtCarNum;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_parking_main);
txtCarNum = (EditText) findViewById(R.id.txtCarNum);
btnSearch = (Button) findViewById(R.id.btnSearch);
btnSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!txtCarNum.getText().toString().matches("[0-9]{2}[ 가 힣- ] ?[0-9]{4}")) {
// 정규표현식을 이용해 입력한 문자열이 올바른 차량 번호가
맞는지 확인
Toast.makeText(getApplicationContext(), " 잘못된 차 번호 형식입니다.",
Toast.LENGTH_SHORT).show();
// 잘못된 차량 번호일경우 토스트 띄움
return;
}
if (!ParkingLot.isParking(txtCarNum.getText().toString().replace(" ", ""))) {
// 차가 주차중인지 확인
Toast.makeText(getApplicationContext(), " 주차중인 차가 아닙니다.",
Toast.LENGTH_SHORT).show();
// 주차중인차가 아니라면 토스트 띄움
return;
}
Intent intent = new Intent(getApplicationContext(), ParkingStatus.class);
// 차량 번호를 이용해 주차상태 액티비티 퐈면에 표시
intent.putExtra("carNum", txtCarNum.getText().toString());
startActivity(intent);
}
});
}
}
5) Parking Lot Status
package com.mdp.mdp.parking;
import android.content.Intent;
import android.support.v4.widget.TextViewCompat;
import android.support.v7.app.AppCompatActivity;
- 983 -