Dropdown menu refuses to work, problem causes application to crash

  android-studio, java

My RegisterSchedule.java page with drop-down-menu doesn’t run, the IDE doesn’t show any error, but when I do the test the application closes saying there are problems, maybe it’s an error in the logic of what I’m trying to do.

The page closes abruptly, causing an error in the application that I don’t identify.

  • Page list_itens.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="16dp"
    android:ellipsize="end"
    android:maxLines="1"
    android:textAppearance="?attr/textAppearanceSubtitle1">
</TextView>
  • Page activity_register_schedule.xml
<androidx.constraintlayout.widget.ConstraintLayout>

        <com.google.android.material.textfield.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:hint="Choose the Local"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
            <AutoCompleteTextView
                android:id="@+id/act_local"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="none"/>
        </com.google.android.material.textfield.TextInputLayout>

        />

</androidx.constraintlayout.widget.ConstraintLayout>
  • Page RegisterSchedule.java
public class RegisterSchedule extends AppCompatActivity {

    AutoCompleteTextView act_places;
    ArrayAdapter<String> adapterplaces;
    String[] places = {"Residence", "Saloon"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register_schedule);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setTitle("Register Schedule");
        
        act_places = findViewById(R.id.act_local);
        
        adapterplaces = new ArrayAdapter<String>(this,R.layout.list_itens,places);
        act_places.setAdapter(adapterplaces);
    }
}

Source: Android Studio Questions

LEAVE A COMMENT