android-widget

Is it possible to get the shortcut layout of Launcher and use it in our own widget?

荒凉一梦 提交于 2019-12-06 14:34:45
I've noticed that the appearience of Dropbox shortcut-like widget to specified folder is consistent with shortcut layout no matter which launcher we use: So I want to make such a widget that behaves and looks like shortcut and is consistent with user's launcher. Is it possible to get the shortcut layout of Launcher and use it in our own widget? Aside from AppWidgets , Android also has a concept of Launcher Shortcuts that are often grouped under the "Widget" label. That Dropbox folder is a Launcher Shortcut. Shortcuts are simple, all data (icon, label, intent) is static, determined at creation

Simple way To Update Widget TextView Periodically

▼魔方 西西 提交于 2019-12-06 13:37:33
I have a widget with two TextView showing the time and date. I simply want this batch of code to happen every second: views.setOnClickPendingIntent(R.id.rl, pendingIntent); java.util.Date noteTS = Calendar.getInstance().getTime(); String time = "kk:mm"; String date = "dd MMMMM yyyy"; views.setTextViewText(R.id.tvTime, DateFormat.format(time, noteTS)); views.setTextViewText(R.id.tvDate, DateFormat.format(date, noteTS)); So I need a simple way to update TextView periodically in the widget so the time changes more than the standard 30 mins. Thanks you may create Handler and Runnable , and then

Android: Is there a method equivalent to XML android:digits?

荒凉一梦 提交于 2019-12-06 12:57:53
In my layout xml, I use the following to define an EditText that can display currency. <EditText android:id="@+id/et1" android:layout_width="210dp" android:layout_height="wrap_content" android:imeOptions= "actionNext" android:inputType="phone" android:digits="0123456789.,$" > However, this is not localized. I want to be able to use the symbol returned by NumberFormat.getCurrencyInstance().getCurrency().getSymbol(); in place of the $ in android:digits . What I don't know is how to set android:digits from within my program. Solved thanks to Agarwal. I just need to read the documentation more

How to customize style from spinner dropdown CHOICES?

本秂侑毒 提交于 2019-12-06 12:26:45
I can customize the background of the selected option on a spinner dropdown using: <item name="android:spinnerStyle">@style/customSpinner</item> <style name="customSpinner" parent="@android:style/Widget.Holo.Light.Spinner"> <item name="android:textColor">#000000</item> <item name="android:background">#000000</item> </style> But I can't manage to change the background and textcolor of the list of options that the dropdown has. How do I achieve that? jiduvah adapter.setDropDownViewResource(R.layout.custom_spinner); custom_spinner.xml - <?xml version="1.0" encoding="utf-8"?> <TextView xmlns

android widget button on press event

谁说我不能喝 提交于 2019-12-06 12:02:40
I'm trying to create a widget button to run an application activity directly through the home screen. the widget change the image when i press it according to the my_button.xml file. but i can't create an event when i click on it. i need to know how to call "onPress" event (for example) in order to call a method inside my main activity. I would appreciate your help i attached the relevant files. widget.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_height="wrap_content" android

How to use OnTabChangeListener?

心不动则不痛 提交于 2019-12-06 11:19:39
I have an android program with 3 tabs. When I click on the “Map Tab” I want it to display “Map is Selected” message as shown in the picture bellow. But if I click on “Name” tab and then come back to the “Map Tab” the second time, the “Map is Selected Again” message wouldn’t show up in the screen. How can I make the “Map” tab display “Map is Selected Again” message each time I choose that tab? Can you edit the following code and show with an example about how to use OnTabChangeListener? public class MapsActivity extends MapActivity implements OnTabChangeListener { @Override public void onCreate

How to show different Activities in Fragment implementation?

元气小坏坏 提交于 2019-12-06 11:13:35
It is my first time using android fragment. I am following this tutorial to implement a fragment. Everything is fine with this tutorial, I successfully get the result like below: In the tutorial, the DetailsFragment simply shows a TextView containing the text of the currently selected item. That's the right part shows just some texts. My question is how to show different activities on the right side instead of text views. What I mean is illustrated in the following image, for example, the area of " 1 " in the image is an activity. How to show different activities when a list item on the left

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

删除回忆录丶 提交于 2019-12-06 09:33:54
问题 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

how to change android Progress Dialog message typeface?

瘦欲@ 提交于 2019-12-06 08:39:57
Who can answer my bellow question ? how to change android Progress Dialog message typeface? Try this way , worked for me : First in java class you have to import this : import android.text.Html; then put this line : progressDialog.setMessage(Html.fromHtml(getString(R.string.progress_txt))); instead of this: progressDialog.setMessage("File downloading"); then in strings.xml write it as this : <string name="progress_txt"> <![CDATA[ <b><font face="serif">File downloading</font></b> ]]> </string> run the app you will find typeface already changed . Hope this help 来源: https://stackoverflow.com

Android AppWidgetProvider's onReceive method never gets called

本秂侑毒 提交于 2019-12-06 08:25:57
问题 I'm working on an android widget. This is my AppWidgetProvider class: public class MyWidgetProvider extends AppWidgetProvider { public static String ACTION_CHARGE = "Charge"; public static String ACTION_BALANCE = "Balance"; public static String ACTION_SEND_BALANCE = "SendBalance"; public static String ACTION_CALL_ME = "CallMe"; @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // Get all ids ComponentName thisWidget = new ComponentName