Android :: Android Date Picker To Input Value Instead Of Keyboard?
Aug 1, 2010
I am attempting to learn Android development and have modified a sample app that loads a web page in a WebView. The web page contains a text input. I want to use the Android DatePicker to input a value instead of the keyboard. The code below almost works. The DatePicker is displayed but throws an unknown error when I select a date and call loadUrl on the WebView in the onDateSet handler to update the value of the text input (end of code sample). I suspect a cross thread issue but I'm not sure.
package com.freeze.android.hellowebview;
import java.util.Calendar;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.DatePicker;
public class HelloWebView extends Activity { WebView webview;
class DateJavaScriptInterface { public void pickDate() { showDialog(0);
} } public void loadScript(String script){
webview.loadUrl("javascript:(function() { " + script + "})()");
} private class HelloWebViewClient extends WebViewClient {
@Override public boolean shouldOverrideUrlLoading(WebView view, String url)
view.loadUrl(url); return true;
} @Override public void onPageFinished(WebView view, String url) {
loadScript("document.getElementById('trips_dateandtime').onfocus = function(
{this.blur();window.DateInterface.pickDate();};");
} } /** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
webview.setWebViewClient(new HelloWebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.addJavascriptInterface(new DateJavaScriptInterface(), "DateInterface");
webview.loadUrl("http://127.0.0.1:8000/mileage/default/index");
} @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
webview.goBack(); return true;
} return super.onKeyDown(keyCode, event);
} @Overrid protected Dialog onCreateDialog(int id) {
switch (id) { case 0:
final Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(this,
mDateSetListener, mYear, mMonth, mDay);
} return null;
} private DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {
@Overrid public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
loadScript("document.getElementById('trips_dateandtime').value = 'test';"); //ERROR
} };
}
View 1 Replies
Jul 21, 2010
Can any one post sample code for a simple date picker in Android.
If date picker is not possible in Android, an option to choose a date is needed.
View 1 Replies
View Related
Apr 5, 2010
I wanted to know whether we can implement both date and time picker in one view...
In iphone app you can pick both date and time through one view. But in android we have date picker and time picker seperately. So, is there any method by which i can get values of both date and time from one view?
View 1 Replies
View Related
Mar 7, 2010
I need someone to test my First app I did. It is reworked and extended version of Android DatePicker app here: Date Picker | Android Developers. I don't have Android creature, because I am out of the Google test area. My app shows Time Duration using the DatePicker Dialog twice
The result can be seen on the image.
Please email me and I'll attach the tDurator.apk for you. I need feedback about the working state of the app when rotating the Nexus 1 device, but anyone having at least Android system 1.5 (level 3 on the SDK) can run the app. The app is signed for release and in not harm to the phone.
View 4 Replies
View Related
Jun 24, 2010
I'm trying to test a date picker scenario on android. I have the date picker which comes up when I click a text view(with id say v) which has a label on it along with a hint "Enter Date".
The problem is that I'm trying to simulate this clicking of the text view and then selecting of the date from the date picker dialog. I cannot find an method call/option in Solo to get hold of the text view (ex:with id say x).
I've been trying to figure it out for the past three days.
Can anyone suggest me a way to go about it?.
View 2 Replies
View Related
Nov 15, 2010
One thing annoys me; The date picking facility that seems to be built into the OS is pretty poor. The three scrolling wheels for year, month and date make it slow to use, and also difficult to work out what date to select if you want something that is, say, 1 week away from today (especially if that leads into another month). It would be better to have a "calendar month" style picker, where you can see an entire month in one go, and switch forwards/backwards a month. Does anyone know if it's possible to change this? Perhaps an app can be installed to replace the standard picker?
View 1 Replies
View Related
Mar 6, 2010
If it was possible to use my physical keyboard to type, and have the android emulator simulate it as if it were a touch (specifically- the button highlights, and letter overlay)
View 1 Replies
View Related
May 10, 2009
I have a class that extends ImageView, which also handles keyboard input, currently via OnKeyListener, which works great with the 1.1 sdk, but how do I port this to the 1.5 sdk? How do I get the soft keyboard to load for this View? I haven't found a ton of documentation regarding the new input framework.
View 2 Replies
View Related
Jul 21, 2010
I'm working on a simple game: when you press a button on the screen, a character will run to certain direction. It's easy to support keyboard input. But, some phone doesn't go with a keyboard or even no a track ball. So I decided to draw a virtual "run" key on the screen (with opengl). When the user press the virtual key, I apply a velocity to the character. And when the user release the key, I disable the velocity to stop the character but there seems to be some touch event noisy. If my finger cannot press still, I will see millions of touch down and touch up events, instead of a single long pressing.
And occasionally, my program captured the touch down event when I touch the screen, but didn't capture touch up event. So my character will keep moving, even no finger is on the screen. I'm wondering if there is some way to reduce the touch event noisy and tell if the user is currently pressing on the screen, instead of only getting an event when touch up and down happen. It seems the system UI can detect long pressing, for example when you put a finger on one item of the list view widget, the entire item turns to orange. I just don't know how to detect pressing in my opengl game.
View 5 Replies
View Related
Oct 21, 2009
Does anyone know how to enable the emote button in soft keyboard input?
View 2 Replies
View Related
Aug 18, 2009
Is is possible to get the virtual keyboard key events on a custom input field ? I tried using keyboardView, but somehow that doesn't work. Is it mandatory to use the android input method classes to get the events?
View 2 Replies
View Related
Dec 4, 2009
I am trying to develop a device which would attach to my Droid and send keystrokes to it, but I need help understanding how the USB OTG works. I have the basic pinout, but is there a reference and instruction set guide anywhere, preferably with example code? Has anyone had any luck developing similar peripherals?
View 2 Replies
View Related
Mar 15, 2010
I'm having a very very strange problem with input and textarea html tags in a WebView. Basically they never seem to gain input focus with the virtual keybaord. which shows a single input box. There is now way just tapping around the screen to get it to accept input. Strangely, if I use my trackball on my G1 to select the field, I can eventually get focus and type in it. For trackball-less things like the N1, that doesn't help though.
View 16 Replies
View Related
Mar 6, 2010
I'm developing and Android app using the 1.6 sdk. I'm using a TimePicker and I don't want the soft keyboard to come up when you click on the digits in the TimePicker. I only want the TimePicker to be changed using the plus and minus buttons. I've tried using android:focusable="false" and android:focusableInTouchMode="false" hoping those would do it, but they didn't seem to do anything. Is there a way to do this?
View 2 Replies
View Related
Feb 20, 2014
There is NO keyboard or text entry widget... I try to create an new account so i get that form that asks for my email and pass... but when I click on it i get a Google vocal input thing that does not do the work anyway... I went to setting, turned it off, still no keyboard...
cannot find any info not even from Ainol them selves.The tablet works with android 4.1.1...Is there anyways to 1) update to a different aNDROID VERSION OR 2) activate the standard keyboard that we find on ALL tablet but mine..
View 1 Replies
View Related
Feb 26, 2012
I was wondering if there was a way to add Japanese as an language input for the Android keyboard? By default, there is no option to add Japanese as a llanguage input, and all other keyboards that have it are either ugly, don't have ICS as an optional theme or just too much, I prefer the stock Android keyboard on ICS over anything else and I'm sure there are some of you that agree. It would be nice to have this and other possible languages as optional languages on this keyboard.
View 2 Replies
View Related
Apr 21, 2010
I am trying to do something that I thought would be simple, yet I still haven't found the right approach. I have a Edit Text field that should only accept unsigned decimal entries. Using android:input Type="number Decimal" in my layout xml file achieves this, however the soft keyboard that is raised with this input Type is the standard keyboard but just uses the alternate view with the number row on top. This is far from ideal for a field that only allows numbers. A much better soft keyboard for numeric entry is the "phone" one. It has all of the numbers and a decimal. Perfect!! Well, except that for the life of me I cannot figure out how to use both the phone keyboard AND allow only numeric entry. I've tried everything I can think of but if I use the phone soft keyboard then the input field also allows things like "(" and any of the other symbols available on that keyboard. Is there any way to get the nice big numeric buttons of the phone keyboard along with only allowing decimal entry? You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
View 3 Replies
View Related
Nov 24, 2010
I am on a non rooted droid incredible. I have the newest version of the swype beta, and I noticed everytime I reboot my phone and I try to write something in swype the keyboard will just flash or something and it wont put in what I tried to write, and it will do this until I change my default input method back to the HTC keyboard and back to swype.
View 9 Replies
View Related
Oct 8, 2009
Inside TextView.java, I have the following code.
InputMethodManager imm = (InputMethodManager)getContext ().getSystemService(Context.INPUT_METHOD_SERVICE); Log.d("tag", " fullscreenmode test: " + imm.isFullscreenMode());
and also, InputMethodManager imm = InputMethodManager.peekInstance(); Log.d("tag", imm.isFullscreenMode());
My phone is in landscape mode. My application has an EditText. My keyboard(virtual/soft) is not visible. I expect the above codes (written inside TextView.java) to print false. But it prints true. How is that possible?
View 2 Replies
View Related
Apr 27, 2009
I wonder it is possible to know whether SIP is showing to user or not. A user application(Activity) can show or hide the Soft Input through the Input Method Manager. There is some APIs to handle the SIP. But I can't find API to know status of SIP(it is on showing or hiding).
When SIP is showing to user. It disturbs the UI of the Activity. So Activity should know about the information related with upper case. How can I know that?
View 3 Replies
View Related
Oct 20, 2010
I was wondering if it is possible to intercept keyboard input on a global level on Android. For example a user types in text into an edittext (does not matter which application) I would like to access said text to check for certain words. Is this even possible with Android's security model (yes I am aware this kind of feature could be used for various wrong things too).
View 1 Replies
View Related
Feb 22, 2010
Is there a way to set the default keyboard type for a html text input field for a webkit view on Android? Can this be done via CSS?
View 2 Replies
View Related
Nov 24, 2009
I have an EditText that is to collect input for a basic calculator. I want to bring up the numeric keyboard, and thus I set android:inputType to numberDecimal|numberSigned. Problem is, the EditText filters out all characters that aren't numeric, such as "(", ")", "/", "*". I have tried overriding this behaviour by setting a custom InputFilter which filters nothing out, but it seems to have no affect on the EditText. Is there any way for me to display the numeric soft keyboard without the filtering behaviour?
View 1 Replies
View Related
Apr 29, 2010
I just got my HTC incredible yesterday from my preorder. I have problem to enable other keyboard such as Swype or others like Chinese input from google. I went to settings-keyboard & language and checked these keyboards, but when I typed text, only the default HTC touch input keyboard popped out, I did not find any key to switch. I did not find a way to disable the touch input keyboard either.
View 2 Replies
View Related
Aug 10, 2010
I live in Belgium, the Dutch part, and we use AZERTY keyboards here. My phone is in Dutch, but I could only choose "Dutch (The Netherlands)". In the Netherlands they speak dutch but use QUERTY. So, what I did was leave my phone in "Dutch (The Netherlands)", but I am using the French AZERTY keyboard.
The problem is, that the autocorrect now is also in French. When i typ a word the autocorrect shows a dutch suggestion, a french sugestion and an english suggestion. By default (pressing the spacebar) the phone chooses the French suggestion. Is there anyway to have an AZERTY keyboard and have the Dutch suggestion by default?
View 1 Replies
View Related
May 26, 2010
So when messing around with Swype the other day I noticed that you can change the keyboard types to 'QWERTY' 'Phone Keypad' and 'Compact QWERTY'.Since I suck at using Swype and I came from a Blackberry pearl with sure type. I switched my keyboard type to Compact Qwerty. The keys are much larger using 2 letters per key, which is great for people like me with big hands.Now I can type so fast on this baby it still auto corrects and everything. To change at your home screen press menu > Settings > Language & Keyword > Touch Input > Keyboard Types.
View 9 Replies
View Related
May 1, 2010
I am at a little over a day with my first smartphone, the Incredible.I'm mostly impressed, but this keyboard issue is really bugging me. Basically, here's what happens: I go to compose a message, I turn the device to landscape mode, and when I press the W key, it does not input regardless of where I push relative to the key. On rare occasions, it will work, but I can't think of anything that I might have done to fix the problem.I tried to sleep/resume, power off/on, remove/replace battery, and calibrate the text input, but there seems to not be any resolution.Has this happened to anyone else? Anyone figure it out? I'd hate to exchange the phone for this one thing, but you don't realize how often you need the W until it won't function!
View 2 Replies
View Related
Apr 2, 2010
Can we download the HTC Keyboard apk file from Here ? I would really like to try voice input to text and email. Swype is great, but would like to have the option. I am using the leaked 2.1 OS as well. Has anybody tried this install from XDA forums? I want to make sure I don't ruin my phone if I do.
View 30 Replies
View Related
Feb 6, 2010
Trying out better keyboard,, been wanting good text input like what comes with 2.1 for a while, the accuracy of the voice input is decent from what i can tell, but when im done recording the text doesnt go into the text field, instead i have to click the text box again and it comes up as a suggestion, is this right..is this how the app is designed..also any other suggestions for 2.1 quality voice input for texting without rooting.
View 7 Replies
View Related
Aug 12, 2010
My father got a Droid X, sister has a one year old Moto Droid. I got my incredible last month and after playing with their phones I concluded my keyboard friggen sucks... the LAG is incredibly annoying. It takes me minutes of slaving over the keyboard to type out texts or emails. When I press a key theres a delay in it appearing in the input. If I even try to speed text everything is a jumbled mess. The portrait keyboard is even worse than the regular one. Anyone else experiencing this? I'm running Swiftkey (the problem remains on the stock input method too), and only a few apps like mail and weather. What the hell could be causing keyboard to lag so much?
View 5 Replies
View Related