android-widget

Can we limit the number of character in edittext of SearchView in Android?

旧巷老猫 提交于 2019-12-29 07:34:11
问题 Is there any api to set the limit no. of characters in SearchView ? 回答1: I am using following code snippet: TextView et = (TextView) searchView.findViewById(R.id.search_src_text); et.setFilters(new InputFilter[]{new InputFilter.LengthFilter(10)}); 回答2: Use this code it will do search only if length is less or equal to 5.You can make it change accordingly like returning true from onQueryTextChange() when text>5. final SearchView searchView = (SearchView) mSearchMenuItem.getActionView();

EditText Alternatives in a Widget? There has to be a way

老子叫甜甜 提交于 2019-12-29 06:42:32
问题 Has anyone ever successfully implemented an EditText in a widget? I realize Android does not support this, however, "Friend Stream" on HTC devices does it... Is this due to an HTC feature? Could I implement this on HTC? Anyone have any crazy creative ideas for implementing a textbox which actually allows typing on a homescreen widget? ANY possible leads on this would be much appreciated! 回答1: Most of this can be google-ed, expept for the style of TextViews (you can not use EditText in widget.

EditText Alternatives in a Widget? There has to be a way

左心房为你撑大大i 提交于 2019-12-29 06:41:33
问题 Has anyone ever successfully implemented an EditText in a widget? I realize Android does not support this, however, "Friend Stream" on HTC devices does it... Is this due to an HTC feature? Could I implement this on HTC? Anyone have any crazy creative ideas for implementing a textbox which actually allows typing on a homescreen widget? ANY possible leads on this would be much appreciated! 回答1: Most of this can be google-ed, expept for the style of TextViews (you can not use EditText in widget.

(Java / Android) Calculate days between 2 dates and present the result in a specific format

和自甴很熟 提交于 2019-12-29 05:22:20
问题 I am trying to do calculate days between 2 dates as follow: Obtain current date Obtain past OR future date Calculate the difference between no. 1 and no. 2 Present the dates in the following format If the result is in past (2 day ago) or in the future (in 2 days) Format will: days, weeks, months, years I tried different ways but couldn't get the result I wanted above. I found out that Android DatePicker dialog box convert date into Integer. I have not found a way to make DatePicket widget to

How to disable Widget updatePeriodMillis?

你。 提交于 2019-12-29 05:04:10
问题 I'm trying to figure out how I can disable the update period on my widgets? I don't need this particular feature. I'm just fine with the widget calling onUpdate when added that's it... 回答1: Just don't include it in your xml and it won't autoupdate, or set it to 0. 来源: https://stackoverflow.com/questions/5641134/how-to-disable-widget-updateperiodmillis

Control screen brightness in android using “ Background Service”

情到浓时终转凉″ 提交于 2019-12-29 05:00:06
问题 Problem:- I want to control the brightness of screen using a background service in android. Existing Solutions:- There are similar question posted in the form in below link:- Adding screen brightness controls to android application Why existing solution will not work? All the solution provided in the link works well with an Activity , but I want to write a Background Service which controls the brightness of the screen. So can you someone please help me find a solution on this issue. Thanks in

Dynamically arrange Buttons around a Circle

假如想象 提交于 2019-12-29 04:19:24
问题 I'm still new to android so I'm not totally familiar with all the view components. I'm struggling with aligning Buttons dynamically around a circle. What I am trying to achieve is to add n buttons (n can change at creation time) to a view that looks like the attached image: I'd like to avoid using absoluteLayout (but I'm open to suggestions if that's the only way to solve it). I already came up with a calculation for the x/y positions for the buttons (ignoring button size for now): int

How to get screen width and height

六眼飞鱼酱① 提交于 2019-12-29 02:45:59
问题 I tried to use following code to get screen width and height in android app development: Display display = getWindowManager().getDefaultDisplay(); int screenWidth = display.getWidth(); int screenHeight = display.getHeight(); but I got NullPointerException for my display , why? how to get screen width and height then? 回答1: If you're calling this outside of an Activity, you'll need to pass the context in (or get it through some other call). Then use that to get your display metrics:

Install home screen widgets progrommaticly

前提是你 提交于 2019-12-29 02:10:31
问题 I have main activity window in my app, which displays three icons on it, also there are 3 home screen widgets in this application. is there a possibility for long press on one of the icons in the main activity, to do the same behavior as when you install the program shortcuts from the application menu when dragging shortcuts on the desktop?(for example this video: http://www.youtube.com/watch?v=DQ37cASti4k) or the user to have to go to home screen \ menu \ add \ widget?? 回答1: The user will

How do I specify EditText inputType as number and password?

别等时光非礼了梦想. 提交于 2019-12-28 16:31:17
问题 I have the following: <EditText android:inputType="number" android:password="true" .... </EditText> I'm getting a warning that "android:password" is deprecated and that I should use inputType instead. Is there a way to specify inputType as number and password? 回答1: Set android:inputType="numberPassword" See this Link 回答2: you should use TYPE_CLASS_NUMBER. EDIT: As this answer android:inputType="textPassword|number" ignore textPassword and only accept number but not password . So you should