Skip to content

Instantly share code, notes, and snippets.

View TheBaileyBrew's full-sized avatar
⌨️
Coding

TheBaileyBrew TheBaileyBrew

⌨️
Coding
  • Grand Rapids, MI
View GitHub Profile
//Okay so this is the basic concept I used in my Now Playing activity.
//Essentially we want to get the current index of the selected song in the Arraylist
//Then create a temporary reference and either add to it or subract from it
//And then refresh the TextViews based on the new position in the ArrayList
//First things first, make sure you have global variables for your TextViews and your ArrayList itself.
ArrayList<songs> SongItems = new ArrayList<>();
//This is called after using .setOnClickListener(this) -- and implementing View.OnClickListener on my public class
@Override
public class LocationDetailActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_detail);
//This is where you'll get the Intent extras
//Then you'll want to assign those strings and integer values to your TextViews, ImageViews just like you would with any other activity.
@TheBaileyBrew
TheBaileyBrew / fragment.xml
Created June 5, 2018 16:41
Array Adapter Access
public class FragmentName extends Fragment {
ArrayList<songItem> SongItems;
ArrayList<genreItem> GenreItems;
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_name, container, false);
songArrayList songs = new songArrayList();
SongItems = songs.getSongList();
GenreItems = songs.getGenreList();