は最終的に私は別のチュートリアルやサンプルを経ることで、この質問の答えを見つけました。
mGender = (Spinner)findViewById(R.id.spinner1);
// Spinner method to read the on selected value
ArrayAdapter<State> spinnerArrayAdapter = new ArrayAdapter<State>(this,
android.R.layout.simple_spinner_item, new State[] {
new State("Male"),
new State("Female")});
mGender.setAdapter(spinnerArrayAdapter);
mGender.setOnItemSelectedListener(this);
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
// Get the currently selected State object from the spinner
State st = (State)mGender.getSelectedItem();
// Show it via a toast
toastState("onItemSelected", st);
}
public void toastState(String name, State st)
{
if (st != null)
{
Gen = st.name;
//Toast.makeText(getBaseContext(), Gen, Toast.LENGTH_SHORT).show();
}
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
あなたはスピナーを作成し、onCreateメソッドの値を割り当てる必要があります。スピナー値を読み取るためのもう1つのクラスの状態。
public class State
{
public String name = "";
public State(String _name)
{
name = _name;
}
public String toString()
{
return name;
}
}
....あなたのすべてに感謝し、あなたlogcat.Alsoは、あなたがこれらのコード行を使用していますか?そしてどのように挿入を管理している場所の詳細を提供する、更新およびデータベース上で削除表示しますか?私はあなたが同じかどうかのための任意のクラスを作成したことを意味ですか? – Hiral
どこにスピナーがありますか?あなたのコードはtextviewを示している..あなたはスピナーやtextviewの価値を取得する必要がありますか? –