Kyla Marquez
Honorary Poster
- Joined
- Sep 12, 2020
- Posts
- 321
- Reaction
- 47
- Points
- 154
Ano po mali sa code po n nito. baguhan lang po.
package com.example.sittingorganizer;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Toast;
public class NewArrangementActivity extends AppCompatActivity {
Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_arrangement);
RadioGroup rgButton = (RadioGroup)findViewById(R.id.rgButton);
EditText yearInput = (EditText)findViewById(R.id.yearInput);
EditText courseInput = (EditText)findViewById(R.id.courseInput);
EditText sectionInput = (EditText)findViewById(R.id.sectionInput);
Button addButton = (Button)findViewById(R.id.addButton);
addButton.setOnClickListener(new View.OnClickListener() {
Override
public void onClick(View v) {
//radio buttons
int checkedId = rgButton.getCheckedRadioButtonId();
if (checkedId == -1){
//No radio buttons are selected
Toast.makeText(NewArrangementActivity.this, "Please Select Year!", Toast.LENGTH_SHORT).show();
}
//EditText conditions
else if (yearInput.length() == 0){
//if year is empty
Toast.makeText(NewArrangementActivity.this, "Please Input Year.", Toast.LENGTH_SHORT).show();
}
else if (courseInput.length() == 0){
//if course is empty
Toast.makeText(NewArrangementActivity.this, "Please Input Course.", Toast.LENGTH_SHORT).show();
}
else if (sectionInput.length() == 0){
//if section is empty
Toast.makeText(NewArrangementActivity.this, "Please Input Section.", Toast.LENGTH_SHORT).show();
}
//radio button condition
else {
Toast.makeText(NewArrangementActivity.this, "Adding Arrangement...", Toast.LENGTH_LONG).show();
//back to main page
Intent startIntent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(startIntent);
}
}
});
}
}
---------------------------------
else if(yearInput.length(), courseInput.length(), sectionInput.length() == 0){
Toast.makeText(NewArrangementActivity.this, "Please Input Details", Toast.LENGTH_SHORT).show();
}
-Kasi po pag sinasalpak ko po ito nag eeror po siya pa help naman po salamat
package com.example.sittingorganizer;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Toast;
public class NewArrangementActivity extends AppCompatActivity {
Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_arrangement);
RadioGroup rgButton = (RadioGroup)findViewById(R.id.rgButton);
EditText yearInput = (EditText)findViewById(R.id.yearInput);
EditText courseInput = (EditText)findViewById(R.id.courseInput);
EditText sectionInput = (EditText)findViewById(R.id.sectionInput);
Button addButton = (Button)findViewById(R.id.addButton);
addButton.setOnClickListener(new View.OnClickListener() {
Override
public void onClick(View v) {
//radio buttons
int checkedId = rgButton.getCheckedRadioButtonId();
if (checkedId == -1){
//No radio buttons are selected
Toast.makeText(NewArrangementActivity.this, "Please Select Year!", Toast.LENGTH_SHORT).show();
}
//EditText conditions
else if (yearInput.length() == 0){
//if year is empty
Toast.makeText(NewArrangementActivity.this, "Please Input Year.", Toast.LENGTH_SHORT).show();
}
else if (courseInput.length() == 0){
//if course is empty
Toast.makeText(NewArrangementActivity.this, "Please Input Course.", Toast.LENGTH_SHORT).show();
}
else if (sectionInput.length() == 0){
//if section is empty
Toast.makeText(NewArrangementActivity.this, "Please Input Section.", Toast.LENGTH_SHORT).show();
}
//radio button condition
else {
Toast.makeText(NewArrangementActivity.this, "Adding Arrangement...", Toast.LENGTH_LONG).show();
//back to main page
Intent startIntent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(startIntent);
}
}
});
}
}
---------------------------------
else if(yearInput.length(), courseInput.length(), sectionInput.length() == 0){
Toast.makeText(NewArrangementActivity.this, "Please Input Details", Toast.LENGTH_SHORT).show();
}
-Kasi po pag sinasalpak ko po ito nag eeror po siya pa help naman po salamat