Skip to main content

Home/ Android Dev/ Group items tagged widget

Rss Feed Group items tagged

Vincent Tsao

Handling User Interaction with Android App Widgets - Developer.com - 0 views

  • An App Widget uses a special display control called RemoteViews. Unlike a regular View, a RemoteViews control is designed to display a collection of View controls in another process. Consequently, you can't simply add a button handler because that code would run in your application process, not in the process displaying the RemoteViews object (in this case, the Home Screen process).
  • In order to handle user interaction with an App Widget, the following tasks must be performed: Set a unique click handler for each App Widget control Have the click handler send a command to a registered receiver Process the command received and perform any action necessary Update the App Widget to reflect the changes
Vincent Tsao

Is it possible to update a widget from an Activity? - Android Developers | Google Groups - 0 views

  • An AppWidgetProvider is a BroadcastReceiver. That gives you two possibilities right off the bat: 1. Have it also handle whatever other Intents you were planning on setting up with a separate BroadcastReceiver, or 2. Send an Intent from whatever component you want to the AppWidgetProvider. In other words, don't worry about trying to talk directly to the app widget (which I suspect is impossible) -- just talk to your code that already talks to the app widget.
    • Vincent Tsao
       
      good explanation
  • I update my widget from within my app, when I delete/add entries to a list. To do this, I have a method (updateWidget) and a static String (UPDATE_ACTION). My updateWidget() method sends a broadcast which is received by the widget class and then calls onUpdate() with the appropriate params: private void updateWidget() {                 Intent i = new Intent(this, TVWidget.class);                 i.setAction(TVWidget.UPDATE_ACTION);                 sendBroadcast(i);         } In TVWidget class: @Override         public void onReceive(Context context, Intent intent) {                 String action = intent.getAction();                 if (action != null && action.equals(UPDATE_ACTION)) {                         final AppWidgetManager manager = AppWidgetManager.getInstance (context);                         onUpdate(context, manager,                                         manager.getAppWidgetIds(new ComponentName(                                                         context, TVWidget.class)                                         )                         );                 }                 else {                         super.onReceive(context, intent);                 }         } This seems to work fine.
Vincent Tsao

Creating a Home Screen App Widget on Android - Developer.com - 0 views

  • onReceive(): The default implementation of this method handles the BroadcastReceiver actions and makes the appropriate calls to the methods shown above. (Warning: A well-documented defect exists that requires the developer to handle certain cases explicitly. See the following note for more information.)
  • Creating a simple App Widget involves several steps: Create a RemoteView, which provides the user interface for the App Widget. Tie the RemoteView to an Activity that implements the AppWidgetProvider interface. Provide key App Widget configuration information in the Android manifest file.
  • An App Widget is basically just a BroadcastReceiver that handles specific actions.
Vincent Tsao

Creating a Home Screen App Widget on Android - Developer.com - 0 views

  • The Android system reuses Intents that match both action and scheme values—the "extras" values are not compared
    • Vincent Tsao
       
      通过设置不同scheme来区别不同的intent
  • In practice, this means the Intent for each App Widget identifier would actually be the same Intent. Fortunately, the solution is straightforward: define a scheme for your App Widget and use it to define unique Intent instances
  • // make this pending intent unique widgetUpdate.setData( Uri.withAppendedPath(Uri.parse( ImagesWidgetProvider.URI_SCHEME + "://widget/id/"), String.valueOf(appWidgetId)));
Vincent Tsao

How to implement a Button on an Android Widget - Stack Overflow - 0 views

  • I am just getting started with Android development and I have created a nice little widget that displays some info on my home screen. However, I now want to implement a Button on my widget that updates the info in my widget TextView.
  • Solved - I can confirm that an Activity is NOT needed if you want create a Button to update an Android AppWidget. I have been able to implement my AppWidgetProvider class such that it registers an android.appwidget.action.APPWIDGET_UPDATE intent-filter with the Broadcast receiver in the AndroidManifest.xml, which then fires the onUpdate event in the AppWidgetProvider class (which in turn then runs the UpdateService).
  • The UpdateService in my AppWidgetProvider class then uses onHandleIntent to run a private buildUpdate method - which registers the onClick event with a call to setOnClickPendingIntent as follows:
  • ...1 more annotation...
  • // set intent and register onclickIntent i = new Intent(this, MyWidget.class);PendingIntent pi = PendingIntent.getBroadcast(context,0, i,0);updateViews.setOnClickPendingIntent(R.id.update_button,pi);
Simon Pan

App Widgets | Android Developers - 1 views

  • To find your minimum width and height in density-independent pixels (dp), use this formula: (number of cells * 74) - 2
    • Simon Pan
       
      why i can't highlight?
    • Vincent Tsao
       
      FYI: You may need a toolbar to highlight, http://www.diigo.com/tools/toolbar
  • how often the App Widget framework should request an update from the AppWidgetProvider by calling the onUpdate() method
  • exactly on time
  • ...6 more annotations...
  • programmatically interface with the App Widget, based on broadcast events.
  • programmatically interface with the App Widget, based on broadcast events.
  • programmatically interface with the App Widget, based on broadcast events.
  • only the event broadcasts
  • when each App Widget is added to a host
  • it includes a loop that iterates through each entry in appWidgetIds,
Kiran Kuppa

New Layout Widgets: Space and GridLayout - 0 views

  •  
    "Ice Cream Sandwich (ICS) sports two new widgets that have been designed to support the richer user interfaces made possible by larger displays: Space and GridLayout."
Vincent Tsao

Widget(s) and Pending intent - Android Developers | Google Groups - 0 views

  • Then i've tried PendingIntent.FLAG_UPDATE_CURRENT i'm no longer crashing, but it always launches the activity with extras were put in the widget that was updated the last. It looks like pending intent is shared among my widget instances
  • I've changed the call to  PendingIntent pending = PendingIntent.getActivity(context, appWidgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT); Now everything is cool except based on discussions i'm not sure how reliable it'll be . ( Doc says it's not supported yet )
Vincent Tsao

putExtra error on AppWidget - Android Developers | Google Groups - 0 views

  • I am just making some AppWidget and I want to pass some Strings through UpdateView to an Activity. But the Bundle is null. I try this: -Widget.java                       Intent defineIntent = new Intent(context, Visor.class);                        defineIntent.putExtra ("org.rss.androides.post2","artist");                        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, defineIntent, 0);                        updateViews.setOnClickPendingIntent (R.id.widget, pendingIntent); -Viewer.java           Bundle b = intent.getExtras();                 if (b == null) {                     finish();                     return;                 } b is always null.
  • Remember that PendingIntents aren't keyed using extras: http://groups.google.com/group/android-developers/msg/b296f43ae70c4587 You could hack the extras through by mangling them into Uri parameters, or if you're using a ContentProvider, just point to a specific row.
  • Or use PendingIntent.FLAG_UPDATE_CURRENT; just be careful that each active instance has its own unique Intent.
Vincent Tsao

Fancy ListViews, Part Six: Custom Widget - 0 views

  •  
    正是我想要的 :)
Vincent Tsao

johannilsson/android-actionbar - GitHub - 0 views

  • This projects aims to provide a reusable action bar widget. The action bar replaces the default title and is therefor located at the top of the screen. The action bar highlights important actions. The action bar pattern is well documented over at Android Patterns. The action bar widget is an Library Project. This means that there's no need to copy-paste resources into your own project, simply add the action bar widget as a reference to your existing project.
Vincent Tsao

Widget Design Guidelines | Android Developers - 1 views

  • In portrait orientation, each cell is 80 pixels wide by 100 pixels tall (the diagram shows a cell in portrait orientation)
  • In landscape orientation, each cell is 106 pixels wide by 74 pixels tall.
Vincent Tsao

How to disable a button on an appwidget? | Hello Android - 0 views

  • RemoteViews can't manipulate a buttons enabled/disabled state, but it can modify its visibility. So the trick is to have two buttons, the real one, and an other which is designed to look like the real one in disabled state, and change witch one is visible.
  • <Button android:id="@+id/startbutton" android:text="Start" android:visibility="visible"></Button> <Button android:id="@+id/startbutton_disabled" android:text="Start" android:clickable="false" android:textColor="#999999" android:visibility="gone"></Button>   <Button android:id="@+id/stopbutton" android:text="Stop"  android:visibility="gone"></Button> <Button android:id="@+id/stopbutton_disabled" android:text="Stop" android:clickable="false" android:textColor="#999999" android:visibility="visible"></Button>
  • RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.widget); remoteView.setViewVisibility(R.id.startbutton, View.GONE); remoteView.setViewVisibility(R.id.startbutton_disabled, View.VISIBLE); remoteView.setViewVisibility(R.id.stopbutton, View.VISIBLE); remoteView.setViewVisibility(R.id.stopbutton_disabled, View.GONE); AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteView);
  • ...1 more annotation...
  • RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.widget); remoteView.setViewVisibility(R.id.startbutton, View.VISIBLE); remoteView.setViewVisibility(R.id.startbutton_disabled, View.GONE); remoteView.setViewVisibility(R.id.stopbutton, View.GONE); remoteView.setViewVisibility(R.id.stopbutton_disabled, View.VISIBLE); AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteView);
Vincent Tsao

Android Endless List - Stack Overflow - 0 views

  • 5 down vote accepted One solution is to implement an OnScrollListener and make changes (like adding items, etc.) to the ListAdapter at a convenient state in its onScrollStateChanged method. The following ListActivity shows a list of integers, starting with 40, adding 10 per scroll-stop.
  • public class Test extends ListActivity implements OnScrollListener {    Aleph0 adapter = new Aleph0();    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setListAdapter(adapter);         getListView().setOnScrollListener(this);    }    public void onScroll(AbsListView v, int i, int j, int k) { }    public void onScrollStateChanged(AbsListView v, int state) {        if(state == OnScrollListener.SCROLL_STATE_IDLE) {                adapter.count += 10;                adapter.notifyDataSetChanged();        }    }    class Aleph0 extends BaseAdapter {        int count = 40;        public int getCount() { return count; }        public Object getItem(int pos) { return pos; }        public long getItemId(int pos) { return pos; }        public View getView(int pos, View v, ViewGroup p) {                TextView view = new TextView(Test.this);                view.setText("entry " + pos);                return view;        }    }}
  • You should obviously use separate threads for long running actions (like loading web-data) and might want to indicate progress in the last list item (like the market or gmail apps do).
Vincent Tsao

Icons for submenu items doesn't show up - Android Developers | Google Groups - 0 views

  • The fact that sub-menus don't support icons. http://developer.android.com/intl/fr/guide/topics/ui/menus.html <http://developer.android.com/intl/fr/guide/topics/ui/menus.html> *Icon Menu * This is the collection of items initially visible at the bottom of the screen at the press of the MENU key. It supports a maximum of six menu items. *These are the only menu items that support icons* and the only menu items that *do not* support checkboxes or radio buttons.
  • Try to use PopUpWindow <http://developer.android.com/reference/android/widget/PopupWindow.html>class. Here you have an example<http://www.anddev.org/how_to_create_a_popupwindow-t1259.html>
Vincent Tsao

libaddressinput - Project Hosting on Google Code - 2 views

  • This widget allows users to input their address, and perform validation on this by talking to an address data server. The UI part is Android-specific, but there is potential to re-use the backend and have different UIs (such as GWT) that interface with it. More information will be written here soon on how to integrate this with your android project and our future plans with regards to making the widget available outside the Android environment.
Vincent Tsao

FrameLayout | Android Developers - 1 views

  • FrameLayout is designed to block out an area on the screen to display a single item. You can add multiple children to a FrameLayout, but all children are pegged to the top left of the screen. Children are drawn in a stack, with the most recently added child on top. The size of the frame layout is the size of its largest child (plus padding), visible or not (if the FrameLayout's parent permits). Views that are GONE are used for sizing only if setConsiderGoneChildrenWhenMeasuring() is set to true.
    • Vincent Tsao
       
      FrameLayout才是最有潜力的布局方式
Vincent Tsao

Using the Action Bar | Android Developers - 1 views

  •  
    到3.0才提供API级别的Action Bar widget Android, 你让我情何已堪!
1 - 20 of 27 Next ›
Showing 20 items per page