tags:

views:

93

answers:

1

Whenever I add an EditText widget to the layout of my home screen widget (confusing how the term "widget" is being used twice in the Android lexicon :-/ ), I receive the "Problem Loading Widget" error box.

Here is the layout I'm attempting; if you remove the EditText, it works...

<

RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">

        <Button
                android:id="@+id/button_generate"
                android:layout_width="54px"
                android:layout_height="54px"
                android:text="Generate"
                android:textSize="10sp"
                android:gravity="center"
                android:layout_alignParentTop="true"
                android:layout_toRightOf="@+id/edittext_key">
        </Button>   

        <TextView
                android:id="@+id/textview_hash"
                android:layout_width="75px"
                android:layout_height="45px"
                android:text="Password"
                android:textSize="11sp"
                android:gravity="left"
                android:layout_alignParentTop="true"
                android:layout_toLeftOf="@+id/edittext_key">
        </TextView>

        <EditText
                android:id="@+id/edittext_data2"
                android:layout_width="200px"
                android:layout_height="50px"
                android:textSize="12sp"
                android:layout_marginTop="20px"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true">
        </EditText> </RelativeLayout>

Now, the Google Search home screen widget has an EditText, so it's obviously legal to implement. Any thoughts on why this is not working?

+2  A: 

Widgets use RemoteViews, which only support a certain number of UI elements. EditText is not included. The Android documentation shows which are supported.

The Google Search home screen widget actually uses a TextView. (Source code)

Andrew Koester
Thank you! This is an awesome answer.
Chris