11111111111111111111111111111111111111111111111111111111111111111111111111111 xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml: 11111111111111111111111111111111111111111111111111111111111111111111111111111 java:java:java:java:java:java:java:java:java:java:java:java:java:java:java: package com.example.spinner_siver; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; import java.lang.reflect.Array; public class MainActivity extends AppCompatActivity { Spinner spinner_1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); spinner_1 = findViewById(R.id.spinner_1); String[] arr1 = {"全部", "纪录片", "动画片", "音乐", "漫画", "舞蹈"}; ArrayAdapter adapter = new ArrayAdapter(MainActivity.this, androidx.appcompat.R.layout.support_simple_spinner_dropdown_item, arr1); spinner_1.setAdapter(adapter); spinner_1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView adapterView, View view, int i, long l) { TextView text = (TextView)view; String str = text.getText().toString(); Toast.makeText(MainActivity.this, "你选择了"+str, Toast.LENGTH_SHORT).show(); } @Override public void onNothingSelected(AdapterView adapterView) { } }); } } 22222222222222222222222222222222222222222222222222222222222222 xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml:xml: