Q:

Attempting set custom arrayAdapter and getting nullpointer exception with listView.setAdapter method, despite apparent pathway

I know these exceptions happen when the code has nothing to grab for the method, but I am not sure why my intended pathway isn't working. I have a custom adapter (MusicAdapter) grabbing a list of items, setting it to a listView.xml file, and setting the screen with setAdapter().
When trying this, I get the error message
Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference.
The MyMusicActivity.java file:
package com.example.android.musicapp;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
import java.util.ArrayList;

public class MyMusicActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    ArrayList<Music> music = new ArrayList<Music>();

    //nonsense examples
    music.add(new Music("The Who", "Won't Get Fooled Again", "Who's Next"));
    music.add(new Music("mother?", "әṭa","as"));
    music.add(new Music("mother?", "әṭa","as"));
    music.add(new Music("mother?", "әṭa","as"));
    music.add(new Music("mother?", "әṭa","as"));
    music.add(new Music("mother?", "әṭa","as"));
    music.add(new Music("mother?", "әṭa","as"));
    music.add(new Music("mother?", "әṭa","as"));
    music.add(new Music("mother?", "әṭa","as"));

    MusicAdapter adapter = new MusicAdapter(this, music);
    ListView listView = (ListView) findViewById(R.id.music_list);
    listView.setAdapter(adapter);
    }
}

The music_item.xml file:
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/music_list"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

The MusicAdapter file:
package com.example.android.musicapp;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.ArrayList;

public class MusicAdapter extends ArrayAdapter<Music> {
public MusicAdapter(Activity context, ArrayList<Music> words) {
    // Here, we initialize the ArrayAdapter's internal storage for the context and the list.
    // the second argument is used when the ArrayAdapter is populating a single TextView.
    // Because this is a custom adapter for two TextViews and an ImageView, the adapter is not
    // going to use this second argument, so it can be any value. Here, we used 0.
    super(context, 0, words);
}

@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Check if the existing view is being reused, otherwise inflate the view
    View listItemView = convertView;
    if(listItemView == null) {
        listItemView = LayoutInflater.from(getContext()).inflate(
                R.layout.music_item, parent, false);
    }

    // Get the {@link Music} object located at this position in the list
    Music currentMusic = getItem(position);

    // Find the TextView in the music_item.xml layout with the artist text
    TextView artistTextView = (TextView) listItemView.findViewById(R.id.artist_text_view);
    // Get the artist from the current music object and
    // set this text on the number TextView
    artistTextView.setText(currentMusic.getArtist());

    // Find the TextView in the music_item.xml layout with the title text
    TextView titleTextView = (TextView) listItemView.findViewById(R.id.title_text_view);
    // Get the title from the current music object and
    // set this text on the name TextView
    titleTextView.setText(currentMusic.getTitle());

    // Find the TextView in the music_item.xml layout with the album text
    TextView albumTextView = (TextView) listItemView.findViewById(R.id.album_text_view);
    // Get the album from the current music object and
    // set this text on the name TextView
    albumTextView.setText(currentMusic.getAlbum());

    // Return the whole list item layout (containing 3 TextViews)
    // so that it can be shown in the ListView
    return listItemView;
    }
}

A:

It looks like you aren't setting the contentView for the activity. The error is saying that the listView is not found. At the top of your onCreate make sure you call setContentView(R.layout.[YOUR_LAYOUT_XML]).

