2

谁能建议如何在单击按钮时清除微调器中的值?

Spinner spinner1;
private static final String[] SpinArray= { "00", "01", "02",
        "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13",
        "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "00" };


adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item,
            SpinArray);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner1.setAdapter(adapter);

    spinner1.setOnItemSelectedListener(new mySpinnerListener());

public void onItemSelected(AdapterView parent, View v, int position,  
            long id) {
        // TODO Auto-generated method stub
        switch(parent.getId()){
        case R.id.spinner1:
            spinner1=parent.getSelectedItem().toString();
            break;

    }

在按钮点击我试图清除使用

spinner1.setAdapter(null); and spinner1.setOnItemSelectedListener(null);

这两个在我的情况下都不起作用..请帮忙

4

2 回答 2

0

spinner1.getAdapter().clear();应该做的伎俩。

正如埃里克在评论中所说,spinner1.getAdapter().notifyDataSetChanged();在那之后打电话。

于 2012-07-28T17:31:58.660 回答
0

单击按钮时,我清除了数组列表并使微调器适配器为空。

arrContent.clear();
spinner1.setAdapter(null);
于 2016-07-26T13:53:23.343 回答