很简单,就是需要自己写两个自己想要的样式的xml布局文件,然后通过Adapter适配器设置就好了。
MainActivity.java 代码:
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 java.util.ArrayList;
import java.util.List;
public class MainActivity extends Activity implements OnItemSelectedListener {
private Spinner mspinner1;
private Spinner mspinner2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mspinner1 = (Spinner) findViewById(R.id.spinner1);
if (mspinner1!=null){
mspinner1.setOnItemSelectedListener(this);
}
mspinner2 = (Spi