There is an empty list to which I want to add a textView. It works when I use addHeaderView
but not when I use addView
. Here is the code:
// Setup Adapter
ArrayList<String> favList = new ArrayList<String>(Arrays.asList(mangas));
favAdapt = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, favList);
favList.clear();
TextView newText1 = new TextView(MyList.this);
String hint = "No favorites selected yet";
newText1.setText("No favorites selected yet");
newText1.setTextColor(Color.rgb(140, 140, 140));
newText1.setTextSize(20);
newText1.setTypeface(Typeface.DEFAULT_BOLD);
favListView.addHeaderView(newText1);
favListView.addView(newText1);
favListView.setAdapter(favAdapt);
Here is the error I get:
addView(View) is not supported by AdapterView.
Why is there an error? Is there a way around it?