public class SearchWidget extends AppWidgetProvider {
@Override
        public void onUpdate(Context context, AppWidgetManager
appWidgetManager,
                        int[] appWidgetIds) {
                // TODO Auto-generated method stub
                // super.onUpdate(context, appWidgetManager, appWidgetIds);
                RemoteViews views = new RemoteViews(context.getPackageName(),
                                R.layout.widget_search);
                ComponentName thisWidget = new ComponentName(context,
                                SearchWidget.class);
                appWidgetManager.updateAppWidget(thisWidget, views);
        }
}

res/layout/widget_search:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
        android:layout_width="fill_parent"
android:layout_height="fill_parent"
        android:orientation="horizontal" android:background="@drawable/
search_bg"
        android:gravity="center_vertical">
        <ImageView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:paddingRight="3dip"
                android:src="@drawable/google_logo" />
        <AutoCompleteTextView
                android:id="@+id/input" android:layout_width="0dip"
                android:layout_weight="1" android:layout_height="wrap_content"
                android:layout_marginTop="1dip" 
android:hint="@string/search_hint"
                android:focusableInTouchMode="false" android:singleLine="true"
                android:selectAllOnFocus="true" android:completionThreshold="1"
                android:inputType="textAutoComplete"
android:imeOptions="actionSearch"
                android:lines="1" android:dropDownWidth="fill_parent"
                android:popupBackground="@drawable/spinner_dropdown_background" 
/>
        <ImageButton android:id="@+id/search_go_btn"
                android:layout_marginLeft="5dip" 
android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
android:src="@*android:drawable/
ic_btn_search"
                style="@style/SearchButton" />
        <ImageButton android:id="@+id/search_voice_btn"
                android:layout_marginLeft="4dip" 
android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
android:src="@android:drawable/
ic_btn_speak_now"
                style="@style/SearchButton" />
</LinearLayout>

I run,message as follows:

W/AppWidgetHostView(  610): updateAppWidget couldn't find any view,
using error
view
W/AppWidgetHostView(  610): android.view.InflateException: Binary XML
file line
#9: Error inflating class <unknown>

it means AutoCompleteTextView is not found. I change it to
TextView,it's right. Also I change it to a view defined by
myself ,it's wrong.  Why? 3x

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to