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!