step1:
spinner_style.xml
spinner_style.xml
<?xml version="1.0" encoding="utf-8"?> <shape
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> <stroke
android:width="1dp"
android:color="@color/colorBlue" /> <corners
android:bottomRightRadius="5dip"
android:bottomLeftRadius="5dip"
android:topLeftRadius="5dip"
android:topRightRadius="5dip" />
</shape>
step2:
<Spinnerandroid:id="@+id/spinner"android:layout_weight="1" android:background="@drawable/spinner_style"android:layout_width="match_parent"android:layout_height="match_parent"android:drawableRight="@android:drawable/arrow_down_float" />step3:public class SpinnerActivity extends AppCompatActivity { String spinner_items[]={ "New illness", "New illness", "New illness", "New illness", "New illness"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_spinner); Spinner spinner=(Spinner)findViewById(R.id.spinner); ArrayAdapter<String> adapter2=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,spinner_items);adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);spinner.setAdapter(adapter2);
No comments:
Post a Comment