gecko/mobile/android/base/preferences/CustomCheckBoxPreference.java

45 lines
1.3 KiB
Java

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.preferences;
import android.content.Context;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
/**
* Represents a Checkbox element in a preference menu.
* The title of the Checkbox can be larger than the view.
* In this case, it will be displayed in 2 or more lines.
* The default behavior of the class CheckBoxPreference
* doesn't wrap the title.
*/
public class CustomCheckBoxPreference extends CheckBoxPreference {
public CustomCheckBoxPreference(Context context) {
super(context);
}
public CustomCheckBoxPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomCheckBoxPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
final TextView title = (TextView) view.findViewById(android.R.id.title);
if (title != null) {
title.setSingleLine(false);
title.setEllipsize(null);
}
}
}