Merge "Handle the case of Preference lists that have header views inserted at the top."
This commit is contained in:
committed by
Android (Google) Code Review
commit
966222ef24
@@ -26,6 +26,7 @@ import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.Adapter;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListAdapter;
|
||||
@@ -190,9 +191,13 @@ public final class PreferenceScreen extends PreferenceGroup implements AdapterVi
|
||||
}
|
||||
|
||||
public void onItemClick(AdapterView parent, View view, int position, long id) {
|
||||
// If the list has headers, subtract them from the index.
|
||||
if (parent instanceof ListView) {
|
||||
position -= ((ListView) parent).getHeaderViewsCount();
|
||||
}
|
||||
Object item = getRootAdapter().getItem(position);
|
||||
if (!(item instanceof Preference)) return;
|
||||
|
||||
|
||||
final Preference preference = (Preference) item;
|
||||
preference.performClick(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user