[Q] EditText scrolling. - Android Q&A, Help & Troubleshooting

When trying to implement an EditText scrolling method, I found that ScrollView apparently can only scroll one page at a time.
To go around that limitation, I decided to scroll my EditText (instead of the ScrollView) by the desired number of pixels. However, the problem is, as soon as I move my cursor, TextEdit updates the view back to the way it was (i.e., equivalent of ScrollTo(0, 0)). So if I need to scroll by 240 pixels, it either scrolls so that I am at the top of Page 1 (0 pixels), or the top of Page 2 (727 pixels).
Does anyone know of some way to go around this limitation without executing "ScrollTo" at the end of every keystroke? I am sure there should be some option to set AutoScroll=Off, or something along those lines...
Edit: and I would prefer to keep the ScrollView there, since I would like my user to be able to scroll using gestures as well. Though it is okay if the user has to push a button to turn off gesture scrolling to allow EditText.scrollBy scrolling, but not both.
OLD QUESTION:
Hello,
I would like to edit some really long texts using the EditText app. When the text gets so large that it does not fit on the screen, the EditText does not automatically scroll to where the cursor is: so I stop being able to see where I'm typing.
I decided to allocate the top and bottom soft keys to allow me to scroll quickly. I tried several functionalities of the soft keys, but they all failed to resolve this problem:
1. Send a command to my EditText to ScrollBy a certain number of pixels. However, at that point I cannot use scrolling gestures to scroll back up to where I was.
2. Send a sequence of TouchEvents to emulate the scrolling, e.g.:
Code:
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1000, MotionEvent.ACTION_DOWN, 100, 200, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1100, MotionEvent.ACTION_MOVE, 100, 190, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1200, MotionEvent.ACTION_MOVE, 100, 180, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1300, MotionEvent.ACTION_MOVE, 100, 170, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1400, MotionEvent.ACTION_MOVE, 100, 160, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1500, MotionEvent.ACTION_MOVE, 100, 150, 0));
scroll.dispatchTouchEvent(MotionEvent.obtain(0, event.getEventTime() + 1600, MotionEvent.ACTION_UP, 100, 140, 0));
However, regardless of playing around with the parameters, and whether the command is sent to my ScrollView or to my EditText, I was still unable to emulate scrolling via a command.
3. Determine where I am using EditText.getLayout.getLineBottom, and then touch that area. For scroll up, that worked good enough; for scroll down, though, if I touch my line, it comes up at the bottom; however, my line is then concealed by the soft keyboard. If I touch below my line, and then update my position, the updating of position happens faster than the touch, and at the end, my position ends up below where I should be.
4. I also tried playing around with different parameters in the XML of my file. Also, no success.
Any suggestions?

Questions should be posted in Q&A forums, not Development forums.
http://forum.xda-developers.com/announcement.php?a=81
See rule #15
Thread moved.

(see updated top message above)

Related

Default Windows Mobile battery icon

Hi there,
The latest devices like the Touch and TyTN II are showing a Windows Mobile default battery icon on the top toolbar (next to the clock, speaker, etc.).
It's a simple battery with 4 "power bars" (and charging indication) to show the battery status.
Is there a way to have this icon in Windows Mobile 6 on the HTC X7500 as well? On other devices which have it, it looks like it's a standard Windows Mobile 6 feature (correct me if it isn't) so shouldn't it be some sort of registry value to set?
See the attachment.
Thanks!!
Try this :
Go to your registry editor and navigate to :
HKEY_LOCAL_MACHINE\Software\Microsoft\Shell\ShowTitleBarClock and change to value to 1, exit using the apps exit function and not your X button, power off for 15 secs and power on to allow the registry edit to flush to the ROM and soft reset.
If the ShowTitleBarClock id not there then just add a new DWORD Value and key in ShowTitleBarClock as teh DWORD Value and input "1" in DWORD Data.
lmf_slacker said:
Try this :
Go to your registry editor and navigate to :
HKEY_LOCAL_MACHINE\Software\Microsoft\Shell\ShowTitleBarClock and change to value to 1, exit using the apps exit function and not your X button, power off for 15 secs and power on to allow the registry edit to flush to the ROM and soft reset.
If the ShowTitleBarClock id not there then just add a new DWORD Value and key in ShowTitleBarClock as teh DWORD Value and input "1" in DWORD Data.
Click to expand...
Click to collapse
The ShowTitleBarClock DWORD is there already and set to 1.
This is for the clock right? I was not talking about the clock, but about the battery icon, as shown in my attached image.
Hi,
Ok ok, I should hit search a little more. I found the solution here:
http://forum.xda-developers.com/showpost.php?p=1250593&postcount=56
Still a pity since the battery only shows when you disable the clock....
that doesn't work for me
I add the new DWORD and it just disappears after it is rebooted. And it changed my clock from showing the time to the date??? all else is the same. I don't get it.
This is how it reads:
The TBOpt was already there
ShowTitleBarClock 1
TBOpt 2

Key definition set (keyboard layout) patcher for stock xv6850

- Note -
You'll probably need to know your way around a hex editor and be able to read basic C in order to make much use of this post. That's the breaks right now. Someone else might decide to make a friendly GUI to wrap things, but right now, this program isn't particularly user friendly.
If, however, you know your way around C, then you might be interested in this post. Feel free to read on if not, though don't expect a lot of help if you're not fluent in the basic prerequisites here, as this project is very much in its early stages.
Incorrect usage of this program can easily crash your phone. Please be sure to read and understand the entire posting before deciding to actually try the program out.
--
I have written a program, keypadpatch.exe, that will patch the microp keyboard tables in the stock Verizon xv6850 keyboard driver. Unlike normal keyboard remapping programs, you can create your own Fn+key combinations on keys where there were previously none. This was important for me as there are a lot of keys on the RAPH500 keyboard without Fn+key combinations, and the keyboard was missing quick access to important keys like semicolon or underscore.
The keyboard layout patcher program will modify the key definition tables in device.exe's instance of keypad.dll. The modifications are done in RAM, so they don't persist across boots. (You could re-run the patching sequence automatically at every boot to make your changes stick if you wish, once you are comfortable with a modified key definition set.) The main advantage of this is that if you happen to break something in the keyboard driver while developing a new set of key definitions, you'll just need to reboot the phone to get things back to normal as opposed to perhaps having to hard reset the device and replace a hex edited driver dll.
The keyboard layout patcher program hardcodes offsets that are specific to the xv6850 keyboard driver. Please don't try it on any other device or firmware combination other than the initial stock Verizon firmware for the RAPH500. Running keypadpatch.exe on any other device or ROM image will likely crash the phone (likely fixable by rebooting it).
The program itself is fairly rough around the edges and developing a new full key definition set is likely not for the faint of heart. Please don't ask me directly for help with making a key definition set.
The program operates in two modes. The first mode will attempt to dump out the currently active key definition array from the running keyboard driver and save it into a file called "microp" (no extension). The file will be placed in the directory within which keypadpatch.exe resides. You will get a confirmation message box if everything works in this mode of operation.
The second mode of operation will read a key definition set file called "microp" from the directory within which keypadpatch.exe resides, and then replace the key defintion array in the keyboard driver's memory image with the one from the key definition set file. If everything works, you won't see any message boxes or any other confirmation. However, if something failed, then you'll either get an appropriate error message, or if you gave keypadpatch.exe a sufficiently invalid microp file, something will probably have crashed. Use carefully at your own peril!
If there is a "microp" file in the directory where keypadpatch.exe resides, the program runs in the second mode of operation (loading a new key definition set). Otherwise, it runs in the first mode of operation (dumping the current key definition set).
Modifying a key definition set involves popping a "microp" file open in a hex editor and twiddling fields by hand right now. There is no friendly program or GUI to make things easier than that.
For the RAPH500, the key definition set is an array of 0x3A elements, each of which is described by the following structure layout:
Code:
#define MICROP_KEY_FLAG_VIRTUAL_KEY ( 0x80000000 )
typedef struct _MICROP_KEY_DEFINITION
{
//
// Virtual keys for primary button press.
//
// { MappedVK, IMEVK, RepeatVK }
//
ULONG VirtualKey[ 3 ];
//
// Secondary characters for function combinations. Set the
// MICROP_KEY_FLAG_VIRTUAL_KEY bit to indicate that the value is actually
// a virtual key code and not a character code.
//
// { Fn + key, 123-mode key, ... }
//
ULONG FunctionChar[ 11 ];
///
// Unknown.
//
ULONG KeyId[ 2 ];
//
// Callbacks to execute when the key is pressed instead of simply inserting
// a key or character code into the input stream. The addresses should be
// valid code within device.exe.
//
// [ 0 ] - Not for Fn- combos.
// [ 1 ] - ??
// [ 2 ] - Not for Fn-combos.
// [ 3 ] - ??
//
ULONG_PTR Callbacks[ 4 ];
} MICROP_KEY_DEFINITION, * PMICROP_KEY_DEFINITION;
Many of the fields of this structure don't currently have a known meaning attached to them. If you figure out what they do, perhaps through disassembly or debugging, or simply trying them out and seeing what happens, I'd appreciate it if you'd post back in this thread.
The fields that do have a particularly relevant meaning are:
- VirtualKey[0], VirtualKey[1]: These need to be set to the virtual key code (VK_* constant) for the virtual key event to generate then the particular physical key is pressed. Usually, the first two VK values are the same, but in some cases (the enter key, for example), they differ. The file \Windows\eT9.Raphael.wwe.kmap.txt may have some clues as to VK-codes for special keys on the RAPH500 (i.e. the "launch tmail.exe key"). Note that VK-codes for numeric keys (0-9) and alphabetical keys (A-Z) are simply the ASCII values for those characters (alphabetical keys always use uppercase characters). See the above link on VK_* constants for more details.
- FunctionChar[0] is the character value (not virtual key code) to generate when a particular physical key is pressed when the Fn-key is active. Normally, this value is simply the raw character code in question (e.g. 0x20 for space, 0x41 for capital A, 0x21 for !). However, if bit 0x80000000 is set, then this value appears to be treated as a virtual key code and not a character code. Using a VK-sequence might be useful if you wanted to map an Fn-key combo to, for example, soft key 1 or soft key 2. Using a character value might be useful if you want to map an Fn-key combo to, for example, semicolon. The keyboard driver takes care of injecting any necessary shift states to make a given character value appear when you provide a raw character value here. For example, setting FunctionChar[0] to 0x21 for a particular key will cause a VK_SHIFT + VK_1 key down / key up sequence to be sent to generate a ! character.
- The last four fields, "Callbacks", desire a little bit of special mention. These are function pointers into device.exe's address space for callbacks that get invoked when a key is pressed. This is how the dedicated "launch tmail.exe" key, and the Fn-Space combo to launch CommManager.exe work on the RAPH500. Setting a particular value to NULL means that the key will be injected into the normal input system instead of being handled by a function call. As a special exemption, keypadpatch.exe accepts the magical value of 0xFFFFFFFF for a particular callback pointer to mean that the currently active callback pointer in device.exe memory space should be left alone. Any other value replaces the active callback pointer in device.exe. You will generally never want to touch this value except to NULL it out for a key that you'd like to reclaim from one of those hardcoded built in shortcut keys.
As I haven't discerned all the meanings of the fields in the key definition structure, there may be additional capabilities (or limitations) here. I've only so far attempted to perform simple tasks like create an Fn-key mapping on the Z key to generate a ' character, where there was no mapping before. It is possible that some special keys might have additional hardcoded handling elsewhere in the keyboard driver and thus might not necessarily be overridable with this method.
Some of the keys in the stock key definition set don't appear to be used for the RAPH500's physical keyboard. For example, there is a "tab" key lurking, despite there being no physical key which uses that definition slot.
Download link for keypadpatch.exe + some example key definition files, one for the stock RAPH500 layout and one that maps Fn-A to -, Fn-S to ", Fn-z to ' in the start of porting something similar to the TITA100 layout to the RAPH500:
http://www.nynaeve.net/Skywing/xv6850/keypadpatch.zip
Acknowledgements:
cmonex provided some invaluable assistance with getting the ball rolling on this project.
- Reserved for future updates. -
Posted a slightly modified key definition set: http://www.nynaeve.net/Skywing/xv6850/keys2008120301.zip.
This key definition set makes the following changes:
Code:
Key New function Old function
=======================================
Fn+Z Left soft key Unassigned
Fn+X Right soft key Unassigned
Fn+S Underscore (_) Unassigned
Fn+D Tab Unassigned
Fn+C Semicolon (;) Unassigned
Mail OK/done Start tmail
Fn+Mail Ctrl* Start tmail
(* Key combinations marked with a * may not be fully working yet.)
Thanks skywing!
This worked great for me, the _underscore_ was especially needed.
Anything else you want me to test? gps?
I'm off work for 5 days in a row so I can play with the phone without too much fear...
_________________
VZW TP - XV6850
I'm still fiddling around with this, I'll probably work on some simple tools tonight to help translate the keymap files to/from a more human-readable format.
/Andrew
kilozebra said:
I'm still fiddling around with this, I'll probably work on some simple tools tonight to help translate the keymap files to/from a more human-readable format.
/Andrew
Click to expand...
Click to collapse
Note that the position in the key definition array isn't what controls what physical keys map to which key definiton slots. That seems to be controlled by the first value in the array (first VK identifier), according to basic tests. Let me know if you discover something more definitive about that, though.
Would this tool work to remap the keys if applied on a non-Verizon CDMA ROM? I'm especially looking into putting Alltel MR1 ROM release on my Verizon TP and fixing the keyboard after that.
TIA

[Q] Scroll ListView programmatically while touching the screen.

Hey guys, maybe the title is little confusing so let's make it clear.
Many of you know the Go Dev Team and the Go Launcher. The Go Launcher has the feature, that allows to scroll the list, while dragging the icon over the boundaries. I need to implement something like this in my app, but I've encountered some problems, maybe my approach is incorrect.
The main problem is, that it is hard to scroll the list while the screen is being touched already.
1. Dispatching touch events to the ListView while touching the screen equals kaboom.
2. Methods like smoothScrollBy are great, but they behave in different way while touching the screen. They will scroll the list only by height of the screen, no matter how many times this method is invoked. After that the ACTION_CANCEL event is generated and I'm loosing control over dragging object, so I can't scroll further.
3. The scrollBy method in View. When using it on ListView it creates empty space while scrolling. I think I am scrolling whole container then, so I don't see any chances here.
And here goes the question. Has anybody tried something like this and can tell more about it?

[Q] Resize and move Everything widget

Hi =)
I have a background on my first screen page.
I try to create an Everything widget, but the position and the size doesn't work like I would like to.
I press my empty screen (with my background image), and add an everything widget. Then I put it nearly the size I want (with long press, resize). So it becomes 90% of the screen.
Then I want it to be 95% of the screen, (almost all width but I want margins). So with resize it doesn't work, it's 90% OR 100% of the screen.
I try to do long press > configure but I don't find any of this type of option.
Same for vertical position: the bottom of this rectangle reaches or 90 or 100% of the screen. When I do long press > configure > background > position and I insert 800 instead of 708 for Y, it doesn't work.
Is there a system of columns so I cannot be more precise than a certain division of the screen?
Thanks =)

[Q] Partially Scrolling HomeScreen

Is it possible in Android to have partially scrolling homescreens? In other words, can you have a homescreen set up so that instead of going page-by-page, you can scroll half a page at a time, or dynamically (i.e., a full swipe = a full screen, half swipe = half screen).
I've done a bit of searching on this, and haven't been able to find anything. I was wondering if anyone has looked into this before.

Categories

Resources