Guest User

Untitled

a guest
Jul 25th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. public class ListActivity extends AppCompatActivity{
  2. @Override
  3. protected void onCreate(Bundle savedInstancedState) {
  4. super.onCreate(savedInstancedState);
  5. setContentView(R.layout.activity_list);
  6.  
  7. //chama lista com nome dos cantigos
  8. //tenho essa lista em uma outra activity "ListaHinosActivity"
  9. String[] hinos = ListaHinosActivity.hinos;
  10. ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, hinos);
  11.  
  12. ListView lv = (ListView) findViewById(R.id.lv);
  13. lv.setAdapter(adapter);
  14. lv.setOnItemClickListener(carregarHinos());
  15. }
  16.  
  17. //Metodo clique da listView
  18. public AdapterView.OnItemClickListener carregarHinos(){
  19. return (new AdapterView.OnItemClickListener() {
  20.  
  21. @Override
  22. public void onItemClick(AdapterView<?> av, View v, int position, long id) {
  23.  
  24. Intent intent;
  25.  
  26. switch (position) {
  27. case 0:
  28. //intent = new Intent(getBaseContext(), layoutActivity.class);
  29. //startActivity(intent);
  30. //break;
  31. case 1:
  32. //intent = new Intent(getBaseContext(), layoutActivity.class);
  33. //startActivity(intent);
  34. //break;
  35. }
  36. }
  37. });
  38. }
  39. }
Add Comment
Please, Sign In to add comment