once valuesa sağ tıkla ve new xml value adınıda gunler koy
içinde :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="gunler">
<item>Pazartesi</item>
<item>Salı</item>
<item>Çarşamba</item>
<item>Perşembe</item>
<item>Cuma</item>
<item>Cumartesi</item>
<item>Pazar</item>
</string-array>
</resources>
içinde :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="gunler">
<item>Pazartesi</item>
<item>Salı</item>
<item>Çarşamba</item>
<item>Perşembe</item>
<item>Cuma</item>
<item>Cumartesi</item>
<item>Pazar</item>
</string-array>
</resources>
layout: activity_maine 1 adet spinner1 isminde spiner yarat
. java : MainActivity
package com.abysamltd.myapplication;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;
public class Main_Activity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Spinner spinner = (Spinner) findViewById(R.id.spinner);
android.widget.Spinner spinner = (android.widget.Spinner) findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.gunler, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
}
public class MyOnItemSelectedListener implements AdapterView.OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
Toast.makeText(parent.getContext(), "Seçilen gün " +
parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}
}