Fix #910
This commit is contained in:
@@ -4,12 +4,37 @@ import android.content.Context
|
||||
import android.content.res.TypedArray
|
||||
import android.support.v7.preference.DialogPreference
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewGroup.LayoutParams
|
||||
import android.widget.NumberPicker
|
||||
import android.widget.EditText
|
||||
import com.github.shadowsocks.R
|
||||
|
||||
class MyNumberPicker(private val context: Context, attrs: AttributeSet = null)
|
||||
extends NumberPicker(context, attrs) {
|
||||
override def addView(child: View) {
|
||||
super.addView(child)
|
||||
updateView(child)
|
||||
}
|
||||
override def addView(child: View, params: LayoutParams) {
|
||||
super.addView(child, params)
|
||||
updateView(child)
|
||||
}
|
||||
override def addView(child: View, index: Int, params: LayoutParams) {
|
||||
super.addView(child, index, params)
|
||||
updateView(child)
|
||||
}
|
||||
def updateView(child: View) {
|
||||
if (child.isInstanceOf[EditText]) {
|
||||
child.asInstanceOf[EditText].setTextSize(dp2px(6))
|
||||
}
|
||||
}
|
||||
def dp2px(dp: Float): Int = (dp*getResources().getDisplayMetrics().density).toInt
|
||||
}
|
||||
|
||||
class NumberPickerPreference(private val context: Context, attrs: AttributeSet = null)
|
||||
extends DialogPreference(context, attrs) with SummaryPreference {
|
||||
private[preference] val picker = new NumberPicker(context)
|
||||
private[preference] val picker = new MyNumberPicker(context)
|
||||
private var value: Int = _
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user