-1
私はスピンナーを実装しようとしていますが、setOnItemSelectedListener、setDropDownViewResource、setAdapterのエラーを解決できません。私は困惑している。私はもっと多くの輸入品を追加しようとしましたが、何もしませんでした。このAndroidスピナー - シンボルを解決できません - setOnItemSelectedListener
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
のonCreateメソッド内
、しかし、後でそれを確認してください仕事のためにあなたがしたい(外部スピナーを宣言
public class MainActivity extends AppCompatActivity implements OnItemSelectedListener {
public final static String EXTRA_MESSAGE = "com.example.FinalProject.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.verb_endings_array, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
// An item was selected. You can retrieve the selected item using
// parent.getItemAtPosition(pos)
}
public void onNothingSelected(AdapterView<?> parent) {
// Another interface callback
}
/** Called when the user clicks the Send button */
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
ありがとう!それは今働く。 –