Here lies your issue:
ArrayAdapter adapter = new ArrayAdapter<String>(this,
R.layout.activity_druglist, fulldruglist);
here the layout you need to provide is the layout used for the item.
but 2 lines above you have :
setContentView(R.layout.activity_druglist);
saying that the layout you provide is the layout used for the container
let's assume that you defined your list in layout R.layout.activity_druglist
and that you defined the layout of each entry of your list in layout R.layout.activity_druglist_item
, you should write:
ArrayAdapter adapter = new ArrayAdapter<String>(this,
R.layout.activity_druglist_item, fulldruglist);
Update: Here is some minimalistic code to display your listview :
MainActivity.java:
public class MainActivity extends AppCompatActivity {
private ListView myListView;
String[] fulldruglist = {"Aspirin","Acetaminophen","Activated Charcoal",
"Adenosine", "Afrin","Albuterol","Amiodarone","Aspirin"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myListView = findViewById(R.id.myListView);
ArrayAdapter adapter = new ArrayAdapter<>(this, R.layout.item,
R.id.textView, fulldruglist);
myListView.setAdapter(adapter);
}
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/myListView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.constraint.ConstraintLayout>
item.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Text" />
</android.support.constraint.ConstraintLayout>
activity_main
is the layout of the activity containing the listview
item
is the layout of the cell's content
textView
is the TextView
that will be used to display each entry of your fulldruglist
References: here or the official documentation