this customer java code allows to proceed to next activity even if no data is enetered. add a constraint which displays a message to fill all fields.
import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.Spinner; import android.widget.SpinnerAdapter; import java.util.ArrayList; import java.util.List; public class CustomerActivity extends AppCompatActivity { EditText editTextName, editTextEmail,editTextPhone, editTextMenu; Button btnBook; Spinner s; String packageName; SpinnerAdapter spinnerAdapter; List<String> packages=new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_customer); editTextName=findViewById(R.id.editTextName); editTextEmail=findViewById(R.id.editTextEmailId); editTextPhone=findViewById(R.id.editTextPhone); editTextMenu=findViewById(R.id.editTextTextPersonName); btnBook=findViewById(R.id.buttonBook); s=findViewById(R.id.spinnerPackage); packages.add("Walima"); packages.add("Barat"); packages.add("Birthday Party"); packages.add("Seminar"); packages.add("School Function"); packages.add("Engagement"); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, packages); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); s.setAdapter(dataAdapter); btnBook.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(CustomerActivity.this,ViewBooking.class); intent.putExtra("name",editTextName.getText().toString()); intent.putExtra("email",editTextEmail.getText().toString()); intent.putExtra("phone",editTextPhone.getText().toString()); intent.putExtra("menu",editTextMenu.getText().toString()); intent.putExtra("package",packageName); startActivity(intent); } }); s.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { packageName=packages.get(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } }
import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.Spinner; import android.widget.SpinnerAdapter; import java.util.ArrayList; import java.util.List; public class CustomerActivity extends AppCompatActivity { EditText editTextName, editTextEmail,editTextPhone, editTextMenu; Button btnBook; Spinner s; String packageName; SpinnerAdapter spinnerAdapter; List<String> packages=new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_customer); editTextName=findViewById(R.id.editTextName); editTextEmail=findViewById(R.id.editTextEmailId); editTextPhone=findViewById(R.id.editTextPhone); editTextMenu=findViewById(R.id.editTextTextPersonName); btnBook=findViewById(R.id.buttonBook); s=findViewById(R.id.spinnerPackage); packages.add("Walima"); packages.add("Barat"); packages.add("Birthday Party"); packages.add("Seminar"); packages.add("School Function"); packages.add("Engagement"); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, packages); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); s.setAdapter(dataAdapter); btnBook.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String name1 = editTextName.getText().toString(); String email1 = editTextEmail.getText().toString(); String phone1 = editTextPhone.getText().toString(); String menu1 = editTextMenu.getText().toString(); if (TextUtils.isEmpty(name1) || TextUtils.isEmpty(email1) || TextUtils.isEmpty(phone1) || TextUtils.isEmpty(menu1)){
Toast.makeText(CustomerActivity.this, "Fields cannot be empty....", Toast.LENGTH_SHORT).show();
} else{ Intent intent=new Intent(CustomerActivity.this,ViewBooking.class); intent.putExtra("name",name1); intent.putExtra("email",email1); intent.putExtra("phone",phone1); intent.putExtra("menu",menu1); intent.putExtra("package",packageName); startActivity(intent); } } }); s.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { packageName=packages.get(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } }
this customer java code allows to proceed to next activity even if no data is enetered....
Edit question this login java code allows to proceed to next activity even if no data is enetered. add a constraint which displays a message to fill all fields. package com.example.Divahalls; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class LoginActivity extends AppCompatActivity { Button btnMoveToDashboard; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); btnMoveToDashboard=findViewById(R.id.buttonMoveToDashboard); btnMoveToDashboard.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(LoginActivity.this,CustomerActivity.class); startActivity(intent); } }); } }
this java code allows to proceed to next activity even if no data is enetered. add a constraint which displays a message to fill all fields. import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class SignupActivity extends AppCompatActivity { EditText editTextName,editTextEmail,editTextPhone,editTextPswd,editTextCPswd,editTextAge,editTextFatherName; Button btnMoveToLogin; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_signup); editTextName=findViewById(R.id.editTextName); editTextFatherName=findViewById(R.id.editTextFatherName); editTextAge=findViewById(R.id.editTextAge); editTextPhone=findViewById(R.id.editTextPhoneNumber); editTextPswd=findViewById(R.id.editTextPswd); editTextCPswd=findViewById(R.id.editTextCPswd); editTextEmail=findViewById(R.id.editTextEmail); btnMoveToLogin=findViewById(R.id.buttonMoveToLogIn); btnMoveToLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("Name",editTextEmail.getText().toString()); if(editTextEmail.getText().toString()=="" &&...
Adroid Studio Error View.setOnClickListener Error: Class 'anonymous class derived from OnClickListener ' must either be declared abstract or implement abstract method 'onClick(View)' in 'OnClickListener ' @Override Error: Method does not override method from its superclass package com.example.gregorybacon.assignment_1; import android.content. Intent; import android. support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view. View; import android.widget.Button; public class MainScreen extends AppCompatActivity f @0verride protected void onCreate(Bundle savedInstanceState) ( super.onCreate(savedInstanceState); setContentView(R. layout.activity main_screen); Button button_unlock-(Button) findViewById(R.id.button_unlock); button_unlock.setOnClickListener(new View.OnClickListener) L aoverride public void OnClick(View view) startActivity(new Intent( packageContext:...
Getting prob in following code.Can anybody suggest how to write if/else if I want to show hint as username/Paswword required if null and password or username did not match if entered wrong and go to next activity if its right.?? public class MainActivity extends AppCompatActivity { EditText userName, pwd; DatabaseHelper helper = new DatabaseHelper(this); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void onClickOk(View v) { if (v.getId() == R.id.LogIn) { final EditText User = (EditText) findViewById(R.id.userName); String...
I should show tables with info after clicking on the buttons in Android Studio. I still can not get what I should write inside OnClick function and how to use containers for printing tables. Please help me! import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.os.Bundle; import android.text.Layout; import android.view.LayoutInflater; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import java.util.ArrayList; public class MainActivity extends AppCompatActivity { LinearLayout container; ListView ListView1; ListView ListView2; ListView ListView3; @Override protected void onCreate(Bundle savedInstanceState)...
Need help to edit the code below. Am using it play a lottery game in Android Studio what i need help with is if play one game u need to clear it up before u could another game. Here is my activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="simpleapps.my.lotteryapplication.MainActivity" android:orientation="vertical" android:layout_margin="10dp" android:weightSum="100"> <TextView android:layout_width="match_parent" android:layout_height="0dp" android:text="Enter White Balls : " android:textColor="#000000" android:textSize="22sp" android:layout_weight="15" /> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal" android:weightSum="100" android:layout_margin="10dp" android:layout_weight="15"> <EditText android:id="@+id/wBall1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="20" android:inputType="number"/>...
Need help to edit the code below. Am using it play a lottery game in Android Studio what i need help with is if play one game u need to clear it up before u could another game. Here is my activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="simpleapps.my.lotteryapplication.MainActivity" android:orientation="vertical" android:layout_margin="10dp" android:weightSum="100"> <TextView android:layout_width="match_parent" android:layout_height="0dp" android:text="Enter White Balls : " android:textColor="#000000" android:textSize="22sp" android:layout_weight="15" /> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal" android:weightSum="100" android:layout_margin="10dp" android:layout_weight="15"> <EditText android:id="@+id/wBall1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="20" android:inputType="number"/>...
Why is my app crashing? Following is an app that takes notes from users and shows it's encrypted string. It also decrypt and encrypted strings. It saves the note in a file and also loads it back. Please help me identify what I am doing wrong? activity_krypto_note.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".KryptoNoteActivity"> <EditText android:id="@+id/key" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:ems="10" android:hint="Cryptographic Key" android:inputType="number" app:layout_constraintEnd_toStartOf="@+id/encrypt" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <Button android:id="@+id/encrypt" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:onClick="enryptClicked" android:text="ENCRYPT" android:textSize="9sp"...
If anyone here is a Java and Android Studio expert please I really need help fulfilling the requirements needed to make a Rock Paper Scissors game. I mainly need Java code to complete it I will post what I have so far I don't have much time left please if anyone can help me I would really appreciate it. Here's what the app is supposed to do... The player should be able to select either Rock, Paper, or Scissors.The app...
I am working on integrating a database to an Android application for a course. Currently, I have all the database code done, but getting all of the EditText fields to enter data into the database has me stuck. Assignment objectives here, so we can be on the same page: Create a second page with a data entry form and the following fields: recipename, category, ingredients, and instructions. Make the Category field a dropdown box that contains the recipe categories listed...