android-widget

how to make headers in android with text and buttons like in iOS

陌路散爱 提交于 2019-12-13 02:42:54
问题 i want to create header in android with text and buttons like in iOS (Text in Cetner and Buttons on right and left side), i have tried but not useful at all,please guide me ... how can i make this one for my app 回答1: Try this. Make header.xml file and put below code in it and use it in any layout file using include . <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap

Widget Layout for 960x540 and 854x480

眉间皱痕 提交于 2019-12-13 02:26:59
问题 Both of these sizes pull from the same layout folder. So...I am wondering how I can create widget that looks good on both? I have attached screen shots to show the 2 displays that are pulling the same resources. Any ideas? 回答1: Both of these sizes pull from the same layout folder. In Android the layout was chosen based on the density of the Devices Different Screen Configuration for eg: (ldpi) screens (~120dpi). (mdpi) screens (~160dpi). (hdpi) screens (~240dpi). (xhdpi) screens (~320dpi).

Android onReceive not called

柔情痞子 提交于 2019-12-13 02:16:16
问题 I'm trying to follow this example: What is the correct way for sharing data among AppWidgetProvider and RemoteViewsService.RemoteViewsFactory As such, I have a RemoteViewsFactory that has this: @Override public void onDataSetChanged() { // Subsequent calls to get the data. newsGetter.updateListFeed(null, new NewsGetter.OnUpdateListFeedFinishedListener() { @Override public void onUpdateListFeedFinished(VolleyError error) { //async return here from volley Intent widgetUpdateIntent = new Intent

how to send sms in a non-activity class?

ぃ、小莉子 提交于 2019-12-13 00:46:58
问题 i have a service class, and a util class. in util class,i send a sms to a phone. but in util class ,there are many functions use params such as context,but the util extends nothing,just a simple class. how to do it ? 回答1: Just like this. set all pendingIntent null. public static boolean smsSender(String to, String msg) { SmsManager smsManager = SmsManager.getDefault(); try { List<String> contents = smsManager.divideMessage(msg); for (String content : contents){ smsManager.sendTextMessage(to,

How do I trigger something from a widget button?

泄露秘密 提交于 2019-12-12 22:09:06
问题 No matter what I do I cannot trigger anything by clicking on a button on a widget. Here is some code I wrote, can anyone tell me why onReceive isn't called when the widget button is clicked? Furthermore, I want to run a function on button click... based on the code below do I have the right idea? public class WidgetProvider extends AppWidgetProvider { @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { Intent intent = new Intent(context,

Displaying a bitmap of arbitrary size without running out of memory

穿精又带淫゛_ 提交于 2019-12-12 19:34:41
问题 How do I display an image of arbitrary size without OOMing or downscaling the image. I dont want to downscale due to zooming and dragging of the picture? If it isnt possible to display an image of arbitrary size, how do I determine the maximum possible size of the image to display, without causing a OOM? 回答1: Bitmap data is aloccated in the Native heap rather than the VM heap. see BitmapFactory OOM driving me nuts for details on how to monitor the Native heap and how big your bitmap can get

Implementing different layouts for RecyclerView but getting class cast erro on onBindViewHolder

梦想与她 提交于 2019-12-12 18:54:52
问题 I'm following this tutorial but I'm getting the following cast error: java.lang.ClassCastException: com.banshai.appetit.controllers.home.OpenRestaurantsViewHolder cannot be cast to com.banshai.appetit.controllers.home.FirstOpenRestaurantVHolder at com.banshai.appetit.controllers.home.RestaurantAdapter.onBindViewHolder The error is being called at onBindViewHolder when trying to cast: FirstOpenRestaurantVHolder firstVH = (FirstOpenRestaurantVHolder) viewholder; . What Am I missing? This is my

Custom tab indicator view

六眼飞鱼酱① 提交于 2019-12-12 18:20:14
问题 I want to reproduce this tab indicator structure (screen is from nova launcher): a dropdown menu and an arrow in the right bottom corner. I have no problem about code but i can't reproduce this appearance. I tried this: mBar.addTab(mBar.newTab().setText(ctx.getString(R.string.tab_actions)).setTabListener(this).setCustomView(R.layout.navigation_spinner)); where mBar is sherlock support actionBar. This is my layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:layout_width=

Scale RectF object in each direction

放肆的年华 提交于 2019-12-12 18:03:41
问题 It's possible to scale a RectF object of by an arbitrary factor in each direction? In practice i would resize of 2 factor a RectF (if RectF is 200X200 i would that he becomes 100x100) 回答1: Try something like this: private void scale(RectF rect, float factor){ float diffHorizontal = (rect.right-rect.left) * (factor-1f); float diffVertical = (rect.bottom-rect.top) * (factor-1f); rect.top -= diffVertical/2f; rect.bottom += diffVertical/2f; rect.left -= diffHorizontal/2f; rect.right +=

Passing widget id to activity

让人想犯罪 __ 提交于 2019-12-12 17:07:28
问题 In my widget provider, I have the following code: for (int widget_id : appWidgetIds) { Log.d(TAG, "Widget Id: " + widget_id); RemoteViews remoteViews; Widget widget; while (true) { try { widget = Widget.load(context, Widget.class, widget_id); break; } catch (Exception ex) { Log.e(TAG, "Exception!", ex); } } // Widget is assigned to user if (widget != null) { remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_with_user); remoteViews.setCharSequence(R.id.user_text, "setText