android-widget

Android: How to use NumberPickerDialog

假如想象 提交于 2019-12-04 21:09:56
Could someone give me an example of how to instantiate a NumberPickerDialog within Activity.onCreateDialog ?( https://github.com/novak/numberpicker/blob/master/lib/src/com/michaelnovakjr/numberpicker/NumberPickerDialog.java ) ? There are examples in a repo called numberpicker-demo for using the widget, but none for the actual dialog. Amongst other approaches I've tried tried something like: return new NumberPickerDialog.Builder(this) .setTitle("Choose Number") .etc.. But this just shows a standard AlertDialog, without the NumberPicker. Thanks! Got it working eventually. There's an example in

Layout for TimePicker-based DialogPreference

ぐ巨炮叔叔 提交于 2019-12-04 21:05:38
I'm writing an app that requires a TimePicker-based preference (two, actually) and I swiped some (Apache-licensed) code from the Android Programming Tutorials book. I've modified it to work a little better, but there's one thing puzzling me. I haven't tried it on an actual device yet but on emulators it now takes into account system settings for 24-hour time display, clears focus on the TimePicker dialog so that the time is read even when edited manually instead of using the arrow keys, and - the problematic part - displays the selected time in the PreferenceScreen. The problem is that I've

Resizable widget android

心不动则不痛 提交于 2019-12-04 20:13:52
问题 Is there any way we can make a resizable widget in android according to the space in home screen? For example if the home screen empty, i can make my large widget. If there other icon, i want to resize my widget become smaller according to the space left in home screen. Thanks. 回答1: Common practice I have seen so far is to make several widgets in different sizes and let the user decide, which size he/she prefers. I am not sure, that there is an automated way to achieve this behavior! 回答2:

RemoteViews for widget update exceeds max bitmap memory usage error

落花浮王杯 提交于 2019-12-04 20:00:17
问题 I have a widget that parses xml feed and display its title and image.In this widget I am using a service that periodically changes the contents(ie, title and image).For this I am using timer class.When we run this widget, some contents are displayed without any problem but after sometime it force closes and shows an error like "RemoteViews for widget update exceeds maximum bitmap memory usage(used:2465280 max:2304000) The total memory can't exceed that required to fill the device's screen

Change buttons' order of DatePickerDialog for Android 4.0.3

。_饼干妹妹 提交于 2019-12-04 19:35:49
I created an DatePickerDialog : DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), this, year, month, day); and show it On Android 4.0.3 (API 15) device, it looks like this: As you see above, the " cancel " button is displaying on the left-hand side while the " Set " button is on the right-hand side. But on Android 2.3.3, the button order is the other way around. So, how can I change the buttons' order of DatePickerDialog in order to show " Set " button on left-hand side, and " cancel " button on right-hand side on Android 4.0.3 device? So, how can I change the buttons'

Permission Denial for intent to external activity

喜欢而已 提交于 2019-12-04 19:13:29
My whole idea is a little more complex, but just to break things down so they're simple and to the point here...I have a button on a widget that i need to open the "places" activity in the official facebook app. Here's the code i'm using: Intent PlacesIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setComponent(new ComponentName("com.facebook.katana", "com.facebook.katana.activity.places.PlacesNearbyActivity")); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, PlacesIntent, 0); views.setOnClickPendingIntent(R.id.places, pendingIntent); I get

Maintaining highlight for selected item in fragment?

我的梦境 提交于 2019-12-04 18:58:38
问题 I have a layout with two fragments. The left hand fragment is a ListFragment using a SimpleCursorAdaptor, the right hand one is populated with details about the item selected from the list in the left fragment. I'm trying to figure out how to make sure the selected item from the ListFragment stays highlighted until another item in the list is selected. After some research I got as far as trying to use android:background="@drawable/item_selector" I can changes the colors for the different

How to update a widget if the related service gets killed?

给你一囗甜甜゛ 提交于 2019-12-04 18:35:43
I have an audio recording app, for which I am currently developing a widget. Recording is performed by an audio engine running in a service put in the foreground state. Whenever the audio engine state changes to pause/play/record, a broadcast is sent, and handled by a receiver which updates the widget. So that clicking on the record button in the widget starts recording, which causes the broadcast to be sent, and in the end the record button to turn red in the widget. Same thing happens if you start recording from within the app instead of the widget. Everything's good so far. Now, if the

How to make custom Indeterminate ProgressBar

痞子三分冷 提交于 2019-12-04 17:15:57
How can I change style of indetermine ProgressBar in Android I need to change color to RED for this progressbar: Can anybody help me? I got the android source code so I saw how they build de spinner loader, and it's very eassy just two steps 1- create a drawable resource in your drawable folder with you image like below (and named it f.i my_loader) <animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/your_image_loader" android:pivotX="50%" android:pivotY="50%" /> 2- in your layout <LinearLayout android:layout_width="wrap_content" android

How to Prevent an Alert Dialog Getting Closed by Back Button

不问归期 提交于 2019-12-04 16:56:57
问题 I have an alert dialog like this: AlertDialog.Builder oyunaBaslaDialog = new AlertDialog.Builder(this); oyunaBaslaDialog.setMessage("A Takımı"); oyunaBaslaDialog.setNeutralButton("Başla!", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { oyunOyna(); } }); oyunaBaslaDialog.show(); This dialog is shown in onCreate method. And I want it just to be closed by the button on it. But Hardware Back Button can also close this dialog without dialog's action