PreferenceWithLongSummary.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* ownCloud Android client application
  2. * Copyright (C) 2014 ownCloud Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. package com.owncloud.android.ui;
  18. import android.content.Context;
  19. import android.text.TextUtils;
  20. import android.util.AttributeSet;
  21. import android.view.View;
  22. import android.widget.TextView;
  23. import android.preference.Preference;
  24. public class PreferenceWithLongSummary extends Preference{
  25. public PreferenceWithLongSummary(Context context) {
  26. super(context);
  27. }
  28. public PreferenceWithLongSummary(Context context, AttributeSet attrs) {
  29. super(context, attrs);
  30. }
  31. public PreferenceWithLongSummary(Context context, AttributeSet attrs, int defStyle) {
  32. super(context, attrs, defStyle);
  33. }
  34. @Override
  35. protected void onBindView(View view) {
  36. super.onBindView(view);
  37. TextView titleView = (TextView) view.findViewById(android.R.id.summary);
  38. titleView.setSingleLine(true);
  39. titleView.setMaxLines(1);
  40. titleView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
  41. }
  42. }