onCreateView() being called too often in custom preference
<p>I have created a Custom preference which has the following constructor</p>

<pre><code>public CoordinatesPreference(Context context, AttributeSet attrs)
{
    super(context, attrs);
    setLayoutResource(R.layout.coordinates_preference);
}
</code></pre>

<p>And I have Overriden <code>onCreateView()</code> so it writes to the log like this:</p>

<pre><code>@Override
protected View onCreateView(ViewGroup parent)
{
    Log.d("test", "Creating Preference view");
    return super.onCreateView(parent);
}
</code></pre>

<p>and my log is full of <code>"Creating Preference view"</code> messages, this creates a laggy feel to scrolling and I believe convert view is supposed to solve this, I had  a look at the preference source code and if convert view is null then <code>onCreateView()</code> is called.</p>

<p>for testing purposes I added this method:</p>

<pre><code>@Override
public View getView(View convertView, ViewGroup parent)
{
    if (convertView == null)
    {
        return super.getView(convertView, parent);
    }
    return super.getView(convertView, parent);
}
</code></pre>

<p>and set a break point. I have found that almost always my convert view is null. and therefore it must create a new view, why is this? and how can I improve this to avoid a laggy preference screen?</p>

<p>EDIT: Changed the way the onCreate is called, now its all android I just use <code>setLayoutResource</code>. but this does not solve the problem...</p>

<p>EDIT2: I have used <code>Debug.StartMethodTracing()</code> and have found as I suspected that 55% of the time spend (when I'm just scrolling up and down) is spend on the Inflation of the preference from the method <code>onCreateView()</code> which is called from <code>getView()</code> when <code>convertView</code> is null.</p>

<p>Thanks, Jason</p>
