android-widget

Handling a button click in a home screen widget

落花浮王杯 提交于 2019-12-11 14:15:09
问题 I am trying to make a home screen widget which will toggle on and off the gps (Location in settings). I still don't understand how to handle a button click event. I took this code from a tutorial online. public class LocationWidget extends AppWidgetProvider { private static String SYNC_CLICKED = "automaticWidgetSyncButtonClick"; @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int count = appWidgetIds.length; String status;

Android ListView with Image and Text; can't display ListView

落花浮王杯 提交于 2019-12-11 13:18:17
问题 I am trying to display ListView with Image and text,I have used Simpleadapter class,But I am unable to display ListView Could any one help me,what i did wrong? Here My Code: public class HostsActivity extends ListActivity { public final static String ITEM_TITLE = "title"; public final static String ITEM_IMAGE = "Image"; private List<HostsProfile> hostsProfile1; List<Map<String, ?>> security = new LinkedList<Map<String, ?>>(); @Override protected void onCreate(Bundle savedInstanceState) { //

Can't find the leak, on my fragment android code

青春壹個敷衍的年華 提交于 2019-12-11 12:14:18
问题 I have a TabLayout, under each tab there is a Fragment (I'm using ArrayPagerAdapter). I've noticed that when I switch many times from a tab to another, my memory usage increase a lot. From my heap snapshot, I can see there are a lot of AutoCompleteTextView instances. So I am convinced that the problem could be here: public class MyFragment { ... @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ... final MultiAutoCompleteTextView

How to get default text size from TextView on widget?

你说的曾经没有我的故事 提交于 2019-12-11 11:05:44
问题 I have a home screen widget with TextView: <TextView android:id="@+id/textView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:ellipsize="none" android:singleLine="true" android:textStyle="bold" /> I need to get the size of this text. I am trying to get default TextView's size text like this: TextView defaultTextView = new TextView(context); float sourceTextSize = defaultTextView.getTextSize(); And sourceTextSize contains 21. But that is wrong value, because

send voice message to another contact number

こ雲淡風輕ζ 提交于 2019-12-11 10:57:48
问题 I have made a program, in which I am sending some text to pre defined contact number , but now I also want to send voice message to that number please let me know how can I do this? To send text SMS I am using below code:- String phoneNumber = "XXXX9"; String message = editLocation.getText().toString(); SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNumber, null, message, null, null); Toast.makeText(getApplicationContext(), "Message Sent!", Toast.LENGTH_LONG)

How to create horizontal menu in android?

末鹿安然 提交于 2019-12-11 10:43:47
问题 I am working on horizontal menu that will open on top of the screen. Layout is something like following, || < || Menu Item1 || Menu Item2 || Menu Item3 || > || I want to put this on top of the screen. It can have more than 3 menu item and it can traverse through previous and next arrow. I started with like this, RelativeLayout ( width - fill_parent) Gallery View ( Here i appended adapter ) There is two problem, - Gallery view contains the space before and after - While scrolling its item gets

Android : How to make a spinner disabled look disabled

不问归期 提交于 2019-12-11 10:02:58
问题 Possible duplicate of How do I make a Spinner's "disabled" state look disabled?. I tried the solution mentioned in the post, ie ((Spinner) spinner).getSelectedView().setEnabled(false); spinner.setEnabled(false); However getSelectedView() returns null. I also tried manually selecting an item and than calling getSelectedView but it still returns null. 回答1: Create a drawable selector in the res/drawable folder like this custonspinner.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns

Android widget preview image

一世执手 提交于 2019-12-11 09:23:10
问题 As I have been seeing out there, most of Android Widget preview images follow a design pattern which contains a simple image Centre-Vertical and left aligned with the same image's big grey shadow below it. See the Android Contacts Widget image: If the user wants to add the widget to the screen dragging it, the logo will be the only image object which is going to be dragged and not its shadow. Trying to emulate this kind of images for my widget, I have created a simple PNG24 with a logo and

multiple instances of widget with separated working clickable ImageView

北城以北 提交于 2019-12-11 09:04:03
问题 I am trying to make ImageView widget, when the user click on the widget, it changes the image. But the problem is when i have multiple instances, and click on one of them, it changes the image in all instances. I have tried the code in here: Updating multiple instances of App Widget in Android but didnt work. This is my code: package com.appwidget.test; import android.app.PendingIntent; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; import android

How to Hide or Disable Minutes widget in Android TimePickerDialog?

二次信任 提交于 2019-12-11 08:48:03
问题 I'm working on an application where i want to give user the ability of just to select Hours and AM/PM but Minutes widget should be fixed as i mentioned. I am using TimePickerDialog. Is there any possibility of doing that? 回答1: I am not sure but you can use Android wheel with Timepicker. http://code.google.com/p/android-wheel/source/browse/trunk/wheel/src/kankan/wheel/demo/TimeActivity.java?r=16 and also check out this link: http://code.google.com/p/android-wheel/ 回答2: There's no direct way.