You are passing a custom layout in your ArrayAdapter
. Here you should pass the resource id of the textview on which you want to show the text. Thats why it is giving this error.
Just call the adapter this way.
listview = (ListView) findViewById(R.id.listview);
adapter = new ArrayAdapter<String>(MainActivity.this,
R.layout.activity_main,R.id.tvname );
here R.id.tvname
is the id of one of the textview in your activity_main.xml
. Or you can create the custom adapter.