i'm new with Android and i'm writing a simple alarm clock application.when i type the string into the EditText like this "10:00,Monday" this string will compare syntax with the defined string if true it'll turn on the AlarmClock. But i don't know how to compare. May you give me an idea? Thanks so much. My app's interface and code below
1.My app's interface https://dl.dropbox.com/u/40382482/Screenshot%20from%202012-10-25%2023%3A51%3A14.png
public class MainActivity extends Activity {
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* Calendar cal = Calendar.getInstance(); SimpleDateFormat date = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat time = new SimpleDateFormat("hh:mm:ss"); final TextView labelDate = (TextView) findViewById(R.id.lblDate); final TextView lableTime = (TextView) findViewById(R.id.lblTime); labelDate.setText(date.format(cal.getTime())); lableTime.setText(time.format(cal.getTime()));*/ final ArrayList<String> setAlarm = new ArrayList<String>(); //nhap noi dung vao edit text final EditText alarmEnter = (EditText) findViewById(R.id.setting); final Button button = (Button) findViewById(R.id.Okay); OnClickListener add = new OnClickListener() { public void onClick(View v) { if(alarmEnter.getText().toString().equals("")) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("Info Missing"); builder.setMessage("Please Enter All Information"); builder.setPositiveButton("Continue", new DialogInterface.OnClickListener() { public void onClick(DialogInterface diablog, int which) { } } ); builder.show(); } else { //compare string in EditText and defined string? } } }; button.setOnClickListener(add); }
if (myDefinedString.equals(myEditText.getText().toString()) { // do something }