I got this error:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.MediaController.setAnchorView(andro id.view.View)' on a null object reference
This is my code
public class SymptomArrayAdapter extends ArrayAdapter<Symptom> { private MediaController mc; public SymptomArrayAdapter(Context context, List<Symptom> objects) { super(context, -1, objects); } @NonNull @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater layoutInflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View listViewItem = layoutInflater.inflate(R.layout.symptomlistitem, parent, false); TextView txtSymptom = (TextView)listViewItem.findViewById(R.id.txtSymptom); final VideoView videoSymptom = (VideoView) listViewItem.findViewById(R.id.videoSymptom); Symptom symptom = this.getItem(position); txtSymptom.setText(symptom.getSymptom()); videoSymptom.setVideoURI(Uri.parse("android.resource://com.example.speechrecogniser/" + (symptom.getVideo()))); videoSymptom.setVisibility(View.VISIBLE); videoSymptom.setMediaController(mc); videoSymptom.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { videoSymptom.start(); } }); mc.setAnchorView(videoSymptom); return listViewItem; } }