Change aspect of Edittext to preference

I created a custom EditTextPreference to show and embed the Edittext in preferences. When I add it to the xml ressources file like this:

        <app.FormEntryPreference
            android:key="pref_key"
            android:title="@string/pref_string"/>

      

I get this result:

image 1

What style do I need (android: Theme.Holo).

When I add my preferences programmatically:

FormEntryPreference form0 = new FormEntryPreference(getActivity().getApplicationContext(), null);   

      

I get a different result:

image2

The style is applied in the layout resource that is used for the EditText:

 <EditText        
    style="@style/Style.that.inherits.from.holo"
    android:inputType="text"
    android:id="@+id/form_id"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
</EditText>

      

Then I would like to get the same shape in both cases.

+3


source to share


1 answer


Ok so a coworker solved the problem and not

FormEntryPreference form0 = new FormEntryPreference(getActivity().getApplicationContext(), null);



I just had to remove "getApplicationContext ()" and it all worked like a charm:

FormEntryPreference form0 = new FormEntryPreference(getActivity(), null);   

      

0


source







All Articles