When I try to look if the Input of the edittext( number) is smaller than the int value, it says I can't compare an < to an EditText. My Value is an int and the Input is for numbers and how I understand is an int for a Number. So why can't I compare them? (If this is easy to solve, I have to say I am a beginner in Android Development)
Code:
package com.teamtreehouse.airport;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class AirPortActivity extends AppCompatActivity {
private EditText nameTextView;
private EditText inputNumberAge;
private Button nextActivityButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_air_port);
nameTextView = (EditText)findViewById(R.id.nameeditText);
inputNumberAge = (EditText)findViewById(R.id.inputNumberAge);
nextActivityButton = (Button) findViewById(R.id.nextActivityButton);
nextActivityButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Integer.parseInt(inputNumberAge.getText().toString()));
String nameOfUser = nameTextView.getText().toString();
int numberAge = 18;
if (inputNumberAge > numberAge) {
Toast.makeText(AirPortActivity.this, "No Permission yet!", Toast.LENGTH_SHORT).show();
}
else
startStory();
String nameOfUserToast = "Hi " + nameOfUser;
Toast.makeText(AirPortActivity.this, nameOfUserToast, Toast.LENGTH_SHORT).show();
}
});
}
private void startStory() {
Intent intent = new Intent(this, AirPortSetup.class);
startActivity(intent);
}
}
Aucun commentaire:
Enregistrer un commentaire