怎么保存spinner的数据到数据库呢?
下面是我的代码,我想要把spinner的值保存到数据库,请问该怎么做?importandroid.app.Activity;importandroid.os.Bundle...
下面是我的代码,我想要把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 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); }}
展开
2013-08-28
展开全部
你可以添加下面的代码: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) { } });
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询