Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old February 6th, 2012, 02:15 PM   #1 (permalink)
New Member
 
Join Date: Feb 2012
Posts: 1
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default Preference text item

Hi guys,

I have created an app that also contains a preference activity, that uses the xml/preferences.xml file.

Apart from the regular controls, I also want to include some explanatory text, that isn't part of any of the control summaries.

I haven't found any good way of doing this, so I decided to create my own preference control. This uses a layout fragment, that looks like this

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="_this_should_be_a_namespace_but_no_links_allowd_http_schemas.android.com_apk_res_android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
    <TextView android:id="@+id/textView"
              android:layout_width="fill_parent"
              android:layout_marginLeft="@dimen/margin_l"
              android:layout_marginRight="@dimen/margin_l"
              android:text="@string/long_explanation"
              android:layout_height="wrap_content"
            android:gravity="center"></TextView>
</LinearLayout>
I have then created a java class that extends android.preference.Preference and in the contructors set:

Code:
this.setWidgetLayoutResource(R.layout.preferences_textview_fragment);
This works fine... only the text is too long to fit in the preference item. The item does not grow with the amount of text I write. It stays fixed.

I then tried to override the getView() method like this, but that didn't make any difference.

Code:
@Override
    public View getView(final View convertView, final ViewGroup parent) {
        final View v = super.getView(convertView, parent);
        final int height = AbsListView.LayoutParams.WRAP_CONTENT;
        final int width = AbsListView.LayoutParams.FILL_PARENT;
        final AbsListView.LayoutParams params = new AbsListView.LayoutParams(height, width);
        v.setLayoutParams(params );
        return v;
    }
Can anyone help me out here and tell me what I am doing wrong... apart from wanting to put legal text in the preference section?

All help is appreciated!

JayPete is offline  
Reply With Quote
Sponsors
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 12:14 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo