Hmn今天有同樣的問題。 我的替代解決方案是隻允許在摘要中顯示更多文本。
剛剛創建自己的CheckBoxPreference的子類,它看起來是這樣的:
public class CheckBoxPreferenceWithLongSummary extends CheckBoxPreference{
public CheckBoxPreferenceWithLongSummary(Context context) {
super(context);
}
public CheckBoxPreferenceWithLongSummary(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CheckBoxPreferenceWithLongSummary(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
TextView summaryView = (TextView) view.findViewById(android.R.id.summary);
summaryView.setMaxLines(10);
}
}
那麼你PreferenceScreen內(我假設你使用XML來設置優先佈局 - 不知道,如果它甚至有可能完全編程)只是你的新的實現替換舊<CheckBoxPreference.../>
像<com.example.whatever.CheckBoxPreferenceWithLongSummary ... />
似乎只是正常工作對我來說,altough我不知道有關findViewById(android.R.id.summary),因爲在父類com.android.internal .R.id.summary被使用,似乎是否定的t直接從Java內部訪問?希望它不只是一個巧合:)
工作完美!你爲我節省了幾個小時,男人。謝謝 – 2016-06-30 15:00:03