android中下拉框的制作,android中下拉框控件——Spinner

在Activity中添加如下代码:

private static final String[] mAPDU={"0x00, 0x84, 0x00, 0x00, 0x08 ","0x00, 0xc0, 0x00, 0x00, 0x0a","..."};

private Spinner spinner;

private ArrayAdapter adapter;

private static int mApduIndex = -1;

@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.iccard);

mQuery = (EditText) findViewById(R.id.textViewQuery);

mRuternData = (EditText) findViewById(R.id.textViewRuternData);

spinner = (Spinner) findViewById(R.id.SpinnerAPDU);

//将可选内容与ArrayAdapter连接起来

adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item,mAPDU);

//设置下拉列表的风格

adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

//将adapter 添加到spinner中

spinner.setAdapter(adapter);

//添加事件Spinner事件监听

spinner.setOnItemSelectedListener(new SpinnerSelectedListener(){});

//设置默认值

spinner.setVisibility(View.VISIBLE);

//使用数组形式操作

abstract class SpinnerSelectedListener implements OnItemSelectedListener{

public void onItemSelected(AdapterView> arg0, View arg1, int arg2,

long arg3) {

mApduIndex = arg2;

}

public void onNothingSelected(AdapterView> arg0) {

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值