Created
May 26, 2017 17:36
-
-
Save bilijo/8eeaf2595d13d5b47101f0ebb7d7876f to your computer and use it in GitHub Desktop.
intent target- damir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.android.mymusicapp; | |
import android.content.Intent; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.View; | |
import android.widget.AdapterView; | |
import android.widget.ListView; | |
import android.widget.TextView; | |
import java.util.ArrayList; | |
public class ClassicArtist extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_classic_artist); | |
// Create an ArrayList of Albums objects | |
ArrayList<Album> classicAlbums = new ArrayList<>(); | |
classicAlbums.add(new Album("Symphonie nº 1 - Beethoven",R.drawable.ic_play_arrow_black_48dp)); | |
classicAlbums.add(new Album("Symphonie fantastique - Berlioz", R.drawable.ic_play_arrow_black_48dp)); | |
// get param from ClassicMusic | |
Intent recupIntent = getIntent(); | |
String vArtistName = recupIntent.getStringExtra("IntentArtistName"); | |
Log.d("ClassicArtist", "IntentArtistName: " + vArtistName); | |
AlbumAdapter albumAdapter = new AlbumAdapter(this, classicAlbums); | |
//********************************************************************* | |
// Find the View that shows a Classic Music album | |
ListView listView = (ListView) findViewById(R.id.listview_album); | |
//--------- begin set clickable item ------ | |
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | |
@Override | |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | |
Intent artistIntent = new Intent(ClassicArtist.this, ClassicAlbum.class); | |
artistIntent.putExtra("artistName ", "Berlioz"); | |
startActivity(artistIntent); | |
} | |
}); | |
//--------- end set clickable item ------ | |
listView.setAdapter(albumAdapter); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment