CheckField Android studio

Published: 05 October 2021
on channel: Fast Programming
3,445
126

CheckField Android studio #python #coding #android #easy #how #short #programming #fast #studio:

package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
Button mybtn;
EditText myedittext;
Toast mytoast;
boolean valid = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

myedittext = findViewById(R.id.editTextTextPersonName);
mybtn = findViewById(R.id.button);

mybtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
checkField(myedittext);
Toast.makeText(MainActivity.this,"Your name is "+myedittext.getText(),Toast.LENGTH_SHORT).show();

}
});


};
public Boolean checkField(EditText textField) {
if (textField.getText().toString().isEmpty()) {
textField.setError("enter your full name please ");
valid = false;
} else {
valid = true;
}
return valid;

}
}


On this page of the site you can watch the video online CheckField Android studio with a duration of hours minute second in good quality, which was uploaded by the user Fast Programming 05 October 2021, share the link with friends and acquaintances, this video has already been watched 3,445 times on youtube and it was liked by 126 viewers. Enjoy your viewing!