android-widget

Android picker widget for arbitrary strings

廉价感情. 提交于 2019-12-07 04:53:41
问题 I'm looking to make a basic picker in Android that looks like the built-in date and time pickers but uses a custom array of strings instead of dates and times: http://developer.android.com/guide/topics/ui/controls/pickers.html This is probably one of the most basic questions and I see lots of custom pickers and wheels floating around, but I would particularly want this to have the same look and feel as the built-in pickers. What is the best way to do this? Edit: so I'm using TimePicker widget

auto scroll a Gallery widget

ⅰ亾dé卋堺 提交于 2019-12-07 04:26:30
问题 I need to implement a gallery which scrolls one item at a time, and which can do 'autoscroll': i.e. every couple of seconds, it automatically scrolls to the next item. As per this thread: Android: Programmatically animate between images in Gallery widget, I extended Gallery, overriding onFling to ignore the fling event and instead simulate a DPAD arrow left or right in order to move a single item at a time: @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,

How to programmatically disable onClick handler on Android AppWidget Button

混江龙づ霸主 提交于 2019-12-07 04:21:50
问题 I have a Button on appwidget, that I need to 'enable'/'disable' programmatically from a Service. First idea was to call setBoolean(R.id.buttonid, "setClickable", false) to disable it, but apparently you can't call setClickable remotely. Another idea was was remove the text label from it with rv.setTextViewText(R.id.buttonid, "") and then remove the click handler by rv.setOnClickPendingIntent(R.id.buttonid, null) . Unfortunately passing null to it causes NullPointerException in in android.app

How to correctly handle click events on Widget

心不动则不痛 提交于 2019-12-07 04:18:59
问题 There is a task to make smt like todo list on widget (with dynamic number of elements), how to organize this list for click support on this elements. I only found how add click event on one widget layout element (with setOnClickPendingIntent ), and how send text to widget element TextView. But it's unclear how handle click events for sub-elements, or how get click coordinates(or item) where was click event. I saw widget " Agenda widget " - and it work fine with clicking on different calendar

Dynamically adding a View to an android widget

天涯浪子 提交于 2019-12-07 04:12:01
问题 I am programmically creating a view at runtime and I want to this view to be added to my linearlayout dynamically at runtime. Here is the code I got: public class Widget extends AppWidgetProvider { @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.main); DemoView dv = new DemoView(context); // Stuck here...How do I add my new dv View to my android widget

Two buttons of Android widgets calling same Activity with different intents

China☆狼群 提交于 2019-12-07 03:50:50
问题 I have a homescreenwidget in Android with two buttons. Both buttons should call the same activity ( class ) just use a different intent plus intent extras, to know which button called the class. For now only button1 is working and calling the activity. I also receive the keyvalue in the called Activity. How can i make the second button work? Here's my code: public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { super.onUpdate(context, appWidgetManager,

Android get Video source path from VideoView

╄→尐↘猪︶ㄣ 提交于 2019-12-07 03:30:41
问题 I have VideoView instance. I need to know video source path from it. Is it possible? Can anybody help me? My code from WebChromeClient class is: @Override public void onShowCustomView(final View view, final CustomViewCallback callback) { super.onShowCustomView(view, callback); if (view instanceof FrameLayout) { final FrameLayout frame = (FrameLayout) view; if (frame.getFocusedChild() instanceof VideoView) { // get video view video = (VideoView) frame.getFocusedChild(); } } } How to get video

Disabling SearchView

心已入冬 提交于 2019-12-07 02:34:19
问题 I'm trying to disable a SearchView from my Activity . I tried the following code : mSearchView.setEnabled(false); mSearchView.setFocusable(false); mSearchView.setClickable(false); But it does not work. SearchView can still be clicked and KeyBoard popps up. I want it to become greyed out and unclickable. How can I accomplish this? 回答1: None of the stated answers were sufficient for my needs, so I would like to provide another one for anybody in the same situation. A SearchView is made up of

Resize android datepicker control

穿精又带淫゛_ 提交于 2019-12-07 01:45:15
问题 How can one resize the initial size of android datepicker control to be smaller or bigger. Is there only way to reimplement it? 回答1: I haven't been able to figure out a way to resize it, but have seen implementations where they utilize the DatePicker as a dialog. The date is rendered as TextView with an edit button, which launches the DatePicker dialog. It saves screen real estate when not editing... http://developer.android.com/resources/tutorials/views/hello-datepicker.html 回答2: To resize

“lateinit” or “by lazy” when defining global android.widget var/val

丶灬走出姿态 提交于 2019-12-06 22:40:08
问题 When defining a global android.widget variable, e.g. TextView , is it preferable to use lateinit or by lazy ? I initially thought using by lazy would be preferred as its immutable but I'm not entirely sure. by lazy example: class MainActivity: AppCompatActivity() { val helloWorldTextView by lazy { findViewById(R.id.helloWorldTextView) as TextView } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) updateTextView