Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build an Interactive Story App Intents and Multiple Activities Getting Text from an EditText

Victor Cuc
Victor Cuc
7,281 Points

Bug with typing in the EditText field. When i type my first letter the text field retracts under the keyboard.

The keyboard stays up, frozen, even if i tap the back button once to retract it. If i tap it a second time, it returns to the home screen.

If I comment the lines dealing with the inputs, the keyboard still crashes, but only sometimes... Is this a problem with the current version of android on my phone?

package com.victorcuc.signalsfrommars;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private EditText nameField;
    private Button startButton;

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

        nameField = findViewById(R.id.nameEditText);
        startButton = findViewById(R.id.startButton);

        startButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String name = nameField.getText().toString();
                Toast.makeText(MainActivity.this, name, Toast.LENGTH_LONG).show();
            }
        });
    }
}
Victor Cuc
Victor Cuc
7,281 Points

I've tested it on an emulated device as well (Nexus 5 API 25 - Android 7.1.1) and seems to be working perfectly fine here. So it probably is a bug with the version on my phone or with GBoard.

Still, is there a fix? (I'm running it on a Google Pixel 2 XL - Android 8.1.0 - API 27)