package pauloescobar.com.co.mispinner; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; public class MainActivity extends AppCompatActivity { String[] dias = {"lunes", "martes","mercoles", "jueves","viernes","sabado","domingo"}; private Spinner spinner; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initComponents(); loadInformacion(); spinnerSelectListener(); } private void spinnerSelectListener(){ spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { Toast.makeText(getApplicationContext(),dias[i],Toast.LENGTH_SHORT).show(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } private void loadInformacion() { ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String> (this,R.layout.support_simple_spinner_dropdown_item,dias); spinner.setAdapter(arrayAdapter); } private void initComponents() { spinner = (Spinner)findViewById(R.id.miSpiner); } }
Paulo Andres Escobar Ingenieria de Sistemas, Orientacion a la Programacion el arte de crear Programas
martes, 6 de marzo de 2018
Cargar un spinner con datos y mostrar un texto cuando se selecciones
Suscribirse a:
Enviar comentarios (Atom)
The top 10 casinos to play online and US casino games - Dr
ResponderEliminarThe best casinos to 태백 출장샵 play 의왕 출장마사지 online and US casino games. Discover the top 용인 출장마사지 10 casino sites in 남원 출장마사지 the USA with bonuses, play slots, blackjack, roulette 김포 출장샵 and more.