I have this constructor in a class that extends AlertDialog.Builder
public CustomDialogBuilder(/*Irrelvant args*/)
{
super(context, R.style.AppTheme_Theme_Dialog_Alert);
//...irrelevant init stuff
setTitle("Name");
setPositiveButton("Ok", positiveClick);
setNegativeButton("Not Okay", negativeClick);
this.listView = new ListView();
this.adapter = new CustomListAdapter(listView);
soundsListView.setAdapter(soundsListAdapter);
soundsListView.setItemsCanFocus(true);
soundsListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
soundsListView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
setView(soundsListView);
}
Inexplicably, this causes the following output from my getView overriden in CustomListAdapter.
Getting view at: 0
Getting view at: 1
Getting view at: 2
Getting view at: 3
Getting view at: 4
Getting view at: 5
Getting view at: 6
Getting view at: 7
Getting view at: 8
Getting view at: 9
Getting view at: 10
Getting view at: 0
Getting view at: 1
Getting view at: 2
Getting view at: 3
Getting view at: 4
Getting view at: 5
Getting view at: 6
Getting view at: 7
Getting view at: 8
Getting view at: 9
Getting view at: 10
Getting view at: 0
Getting view at: 1
Getting view at: 2
Getting view at: 3
Getting view at: 4
Getting view at: 5
Getting view at: 6
Getting view at: 7
Getting view at: 8
Getting view at: 9
Getting view at: 10
20 or more times. This is a massive bottleneck. It causes a solid 5+ seconds of lag when my Dialog is constructed. I can not optimize my getView method anymore as I am using a ViewHolder and it is a light method aside from reading a database row to make get the values for the ViewHolder.
As you can see, I am already setting the width and height to MATCH_PARENT to no avail as this post suggests.
Is there anyway to stop this excessive calling? It is a fairly large bottleneck in my app.