compile 'com.loopj.android:android- async-http:1.4.9'
y despues en el manifest <uses-permission android:name="android.permission.INTERNET" />
Paulo Andres Escobar Ingenieria de Sistemas, Orientacion a la Programacion el arte de crear Programas
compile 'com.loopj.android:android- async-http:1.4.9'
y despues en el manifest <uses-permission android:name="android.permission.INTERNET" />
para esto las imagenes se meten en drawable y para los sonidos se crea una carpeta llamada raw
package pauloescobar.com.co.lagranja; import android.media.MediaPlayer; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void playCaballo(View view) { MediaPlayer mp = MediaPlayer.create(this,R.raw.gato); mp.start(); } public void playCerdo(View view) { MediaPlayer mp = MediaPlayer.create(this,R.raw.cerdo); mp.start(); } public void playGato(View view) { MediaPlayer mp = MediaPlayer.create(this,R.raw.gato); mp.start(); } }
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); } }
package pauloescobar.com.co.listview; 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.ListView; import android.widget.Toast; public class MainActivity extends AppCompatActivity { String[] ciudades = {"medellin", "bogota","san andres", "cartagena","rioengro","santamarta"}; ListView listViewCiudades; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initComponents(); loadInformacion(); onClickList(); } private void onClickList() { listViewCiudades.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { Toast.makeText(getApplicationContext(),getString(R.string.ciudad_seleccionada) + getCiudadById(position),Toast.LENGTH_SHORT).show(); } }); } private void loadInformacion() { ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,ciudades); listViewCiudades.setAdapter(arrayAdapter); } public void initComponents(){ listViewCiudades = (ListView) findViewById(R.id.listViewCiudades); } private String getCiudadById(int posicion){ return ciudades[posicion]; } }