Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – My second and third intents are not working; when I type 13 or higher, it goes to intent1

Posted on November 11, 2022 By

Solution 1 :

getInputType() is not a value from EditText, it’s a type of EditText, e.g. textPersonName, textPersonName, etc.

if you want value, you need to use getText()

String value= enterage.getText().toString();
int intValue = Integer.parseInt(value);

Problem :

[It should be that when I type 13-17, it goes to intent2 and when I type 18 or higher, it goes to intent3, but this is not the case.

public class nextscreen extends AppCompatActivity {

MediaPlayer mediaPlayer;
public Button btn;
public EditText enterage;

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

    mediaPlayer = MediaPlayer.create(nextscreen.this, R.raw.background_music);
    mediaPlayer.setLooping(true);
    mediaPlayer.start();

    btn = (Button) findViewById(R.id.agebutton);
    enterage = (EditText) findViewById(R.id.enterage);
    
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int inputage = enterage.getInputType();

            if (inputage <= 12) {
                Intent int1 = new Intent(nextscreen.this, nextscreen1.class);
                startActivity(int1);
            }


            else if (inputage <= 17){
                Intent int2 = new Intent(nextscreen.this, nextscreen2.class);
                startActivity(int2);
            }


            else {
                Intent int3 = new Intent(nextscreen.this, nextscreen3.class);
                startActivity(int3);
            }

]1

Comments

Comment posted by Community

Please clarify your specific problem or provide additional details to highlight exactly what you need. As it’s currently written, it’s hard to tell exactly what you’re asking.

READ  [FIXED] java - Show app icon on contact details in Android
Powered by Inline Related Posts
Android Tags:android, android-studio

Post navigation

Previous Post: [FIXED] java – is permission needed when choosing image from gallery on android?
Next Post: [FIXED] Android Java: How to get component in a custom view? (Trying to access components via findByViewId and get null)

Related Posts

[FIXED] I want a listener on Storing Bitmap Android Android
[FIXED] android – Navigation Architecture Component – BottomNavigationView avoid fragment reloading Android
[FIXED] flutter – Android Studio project structure item missing from file menu Android
[FIXED] Android app built with React Native and Expo still asking for app permissions Android
[FIXED] Disable selectAll in Android Android
[FIXED] android – Alarm is getting trigger even for past time Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is the rising action in Julius Caesar?
  • How do you secure a rope to itself?
  • Does waterproof laminate scratch easily?
  • What makes a building prewar?
  • What can you learn in a month without alcohol?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme