import android.view.ViewGroup;
import android.widget.AbsListView.LayoutParams;
import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
ApiCompatibilityUtils.setBackgroundForView(layout, new DropdownDividerDrawable());
}
- DropdownItem item = getItem(position);
-
- TextView labelView = (TextView) layout.findViewById(R.id.dropdown_label);
- labelView.setText(item.getLabel());
-
- labelView.setEnabled(item.isEnabled());
- if (item.isGroupHeader()) {
- labelView.setTypeface(null, Typeface.BOLD);
- } else {
- labelView.setTypeface(null, Typeface.NORMAL);
- }
-
DropdownDividerDrawable divider = (DropdownDividerDrawable) layout.getBackground();
int height = mContext.getResources().getDimensionPixelSize(R.dimen.dropdown_item_height);
if (position == 0) {
R.color.dropdown_divider_color));
}
}
- layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, height));
+
+ // Note: trying to set the height of the root LinearLayout breaks accessibility,
+ // so we have to adjust the height of this LinearLayout that wraps the TextViews instead.
+ // If you need to modify this layout, don't forget to test it with TalkBack and make sure
+ // it doesn't regress.
+ // http://crbug.com/429364
+ View wrapper = layout.findViewById(R.id.dropdown_label_wrapper);
+ wrapper.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, height));
+
+ DropdownItem item = getItem(position);
+ TextView labelView = (TextView) layout.findViewById(R.id.dropdown_label);
+ labelView.setText(item.getLabel());
+
+ labelView.setEnabled(item.isEnabled());
+ if (item.isGroupHeader()) {
+ labelView.setTypeface(null, Typeface.BOLD);
+ } else {
+ labelView.setTypeface(null, Typeface.NORMAL);
+ }
TextView sublabelView = (TextView) layout.findViewById(R.id.dropdown_sublabel);
CharSequence sublabel = item.getSublabel();
sublabelView.setVisibility(View.VISIBLE);
}
+ ImageView iconView = (ImageView) layout.findViewById(R.id.dropdown_icon);
+ if (item.getIconId() == DropdownItem.NO_ICON) {
+ iconView.setVisibility(View.GONE);
+ } else {
+ iconView.setImageResource(item.getIconId());
+ iconView.setVisibility(View.VISIBLE);
+ }
+
return layout;
}