我想将编辑过的微调器值存储在数据库中

时间:2010-12-29 06:05:52

标签: android sqlite spinner

我的编码运行良好。但是我想将编辑过的微调器值存储在数据库中。它是如何完成的。我的代码是

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class tooo extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Spinner localSpinner = (Spinner)findViewById(R.id.color_spinner);

        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.color_array, R.layout.my_normal_spinner_item_style);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        localSpinner.setAdapter(adapter);    
    }
}

我的simple_spinner_dropdown_item.xml

1 个答案:

答案 0 :(得分:0)

在代码

中设置适配器后添加以下内容
localSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() 
    {
        public void onItemSelected(AdapterView parentView, View childView, int position, long id) 
        {
            String text = localSpinner.getSelectedItem().toString();
            //The above text variable has the selected value of spinner
        }
        public void onNothingSelected(AdapterView parentView) 
        {
        }
    });

为什么不在上一篇文章中编辑问题而不是创建新帖子