在此代码中,我在微调器中添加了从 600000 到 600113 的 pincode 数字,但我希望第一个位置为空。当用户仅单击时,应显示该项目。请看我的代码 -
final String[] myarray=new String[114];
for(int i=0;i<114;i++)
{
myarray[i]=String.valueOf(a);
a++;
}
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(MainActivity.this,
android.R.layout.simple_spinner_dropdown_item,myarray);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
addnum_spinner.setAdapter(adapter);
lv.setOnItemClickListener(itemClickedListener);
//Spinner click
addnum_spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
// your code here
String value = myarray[position];
//
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
// your code here
}
});