ListView listView = findViewById(R.id.list_view); View searchView = getLayoutInflater().inflate(R.layout.search_view, null); listView.addHeaderView(searchView);In this example, we first get a reference to the ListView from our layout XML file. Then, we inflate a searchView layout file and use the addHeaderView method to add it to the top of the ListView. The package library for the ListView class is android.widget.