MainActivity.java fayliga quyidagi kod yoziladi:
Button button = findViewById(R.id.btn);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), NewActivity.class);
startActivity(intent);
}
});
NewActivity.java faylida quyidagi kod ayoziladi:
Button b1 = findViewById(R.id.buy);
Button b2 = findViewById(R.id.buy2);
Button b3 = findViewById(R.id.buy4);
Button b4 = findViewById(R.id.buy5);
Button b5 = findViewById(R.id.buy6);
Button b6 = findViewById(R.id.buy9);
Button b7 = findViewById(R.id.buy7);
Button b8 = findViewById(R.id.buy8);
Button b9 = findViewById(R.id.buy10);
Button b10 = findViewById(R.id.buy11);
Button b11= findViewById(R.id.buy13);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
b3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
b4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
b5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
b6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
b7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
b8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
b8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
b9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
b10.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
b11.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SavatActivity.class);
startActivity(intent);
}
});
SavatActivity.java fayli kodlari:
Button button = findViewById(R.id.sent);
EditText editText = findViewById(R.id.tel);
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isAllFieldsFilled()) {
// Keyingi oynaga o'tish
Intent intent = new Intent(getApplicationContext(), NatijaActivity.class);
startActivity(intent);
} else {
// Ogohlantirish ko'rsatish
showErrorMessage("Barcha ma'lumotlarni to'ldiring");
}
}
private void showErrorMessage(String message) {
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
}
private boolean isAllFieldsFilled() {
String phoneNumber = editText.getText().toString().trim();
return !phoneNumber.isEmpty();
}
});
|