[Q] Mulitple surfaceviews - Android Software Development

Hey,
I know that using multiple surfaceviews is not a good idea. With that aside...
I am trying to make an onscreen joystick to add as an option to a game I am working on. I have a tablet so there is a big enough screen for multiple people to play on the one device, but I want to be able to control from joysticks rather than touching the whole of the screen (as you can imagine 4 people would get in each others way).
I am currently using a surfaceView to display the game on and for single player the normal touchscreen is fine, but I dont quite know how to add the joystick version without putting the joystick on the game map (something I want to avoid).
I have created another layout.xml file to handle my second option, and using a relativeLayout I can put the surfaceview between two other controls (like buttons etc). I dont just want to but 4 buttons for left etc, as I want to have vairable speed which a current_touch_position - centre_joystick_position would achieve.
Sorry for the long entry, but I felt like I needed to justify myself.
Any ideas?
Many thanks,
Steaky

So if anyone is in the same situation as me heres how I solved it.
Using RelativeLayout as a base I split the screen into 3 sections - relativeLayout, surfaceView and relativeLayout. I created a Joystick class that extends the class Button (might change to Bitmap in the future, but I'll go into that). Then put this line into the XML wherever I wanted a joystick
Code:
<view class="com.steaky.game_1.Joystick" android:id="@+id/button_JS2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minHeight="100dip" android:minWidth="100dip" android:layout_alignParentRight="true"></view>
I used the setOnTouchListener to take the user input and control the cursor.
One problem I encounter was that Buttons only draw when they are no longer being pressed, so the crosshair showing where the user was ressing (and dragging) only updated when the user lifted their finger.

Related

Scroll bar control, accessing, WM_HSCROLL

Hi all (and no worries vijay555.... I'm new to forums and my Axim x51v... hope I'm doing this right... and thank you for your assistance!!!)
Keystrokes as code?
Specifically Excel Mobile keyboard shortcut Alt-PgUp/Dn (scrolls one screen width left/right)
I've created several Keystroke "routines" to minimize stylus use in Excel Mobile. I've mapped to hardware buttons, and they all work great... except Alt-PgUp(and PgDn). In Excel, these key combos will scroll one screen left or right, respectively. Other similarly-coded "routines" work as expected.
I've worked around this for now by recording screentaps in Excel's horizontal scrollbar. Unfortunately, the location of that s/b depends on whether SIP is active. If it is, the vertical co-ordinates of the screentaps become irrelevant and/or potentially destructive to my intended result. I prefer to avoid "position dependent" commands whenever possible for obvious reasons.
I have several other programs at my disposal to effect the Alt-PgUp/Dn shortcut(s).... IF I knew how to define the values(?) of Alt-PgUp/Dn in a script.
(MortScript, PHMkeys, Pen Commander, Spb FullScreenKb, PDA MediaKb)
I've been all over the web, and I think I understand keystroke scan-codes and values... and how they work together. Is there something akin to an ASCII "value" for this key combination? (099/0A1; 073/081; 153/161)?
Any ideas are appreciated. I've no aversion to research or work, but can't figure out what to ask or where to look further.
(I just really need a more direct/reliable functionality to scroll entire screen at a time left/right.)
Thanks in advance if anyone can help.
Dell Axim x51v WM5 (if it matters)
p.s. Thanks to Vijay555 for "permitting" this post here, and for putting me on the track of WM_HSCROLL (which I haven't had a chance to study yet).
Guys, just to say, there's never any reason to ask me for permission to post. As far as I'm concerned, post whatever you want using your own good sense!
pro-fit2:
Try something like this, as we discussed in the other thread:
Code:
//get current foreground window
HWND CurrentForegroundWindow_hwnd;
CurrentForegroundWindow_hwnd=GetForegroundWindow();
SendMessage (CurrentForegroundWindow_hwnd, WM_VSCROLL, SB_PAGEDOWN, 0);
V

converter program (finger friendly) need suggestions

Hi wanted to create my first program..
right now Im trying to make a unit converter that is finger friendly..
so far I've tested it and here is what I have so far..
any suggestions? regarding the buttons positions, the interface, etc?
thanks
Hi Providense,
Looks good so far.
Do you have a development schedule as to what it will convert?
Keep it up.
John
Provedence,
It seems that some people like to have a configuration facility.
So perhaps some suggestions:-
Favorites so that the list can be tailored to favorites for that person to save a more compact list of 'things to convert'
I would be happy to have any theme for now but cooks may prefer to add there own theme.
I have used this type of function with calculator type programs but they can become unweildy so one that is specific would be usefull.
Thanks
John
thanks Johny1fin
as of now these are the things i've done
Temperature:
degree Celsius
degree Fahreheit
degree Rankine
degree Reaumur
kelvin
Acceleration: (still doing it right now)
centigal
centimeter/square second
decigal
decimeter/square second
dekameter/square second
foot/square second
g-unit(G)
gal
galileo
gn
grav
hectometer/square second
inch/square second
kilometer/hour second
kilomter/square second
meter/square second
mile/hour minute
mile/hour second
mile/square second
milligal
millimeter/square second
still a long way to go. But the Acceleration should be done by today.
Then I'll add Area, Date/Time and etc
I like the idea of favorites. I'll see if i can implement that. Im still a beginner at programming. Using VB.net 2003 right now
oh by the way. Here's the main menu, where I will put all the buttons
providence said:
Hi wanted to create my first program..
right now Im trying to make a unit converter that is finger friendly..
so far I've tested it and here is what I have so far..
any suggestions? regarding the buttons positions, the interface, etc?
thanks
Click to expand...
Click to collapse
Providence,
It may be a limitation of the APIs but could the vertical scroll buttons be next to each other horizontally rather than vertically as this may produce larger buttons?
John
Look nice.. however, on the finger friendly issue, you may want to avoid the scroll list (on your first screenshot) and have another screen for the choice of (say) different temperature units. Something like, making a screen (of your second shot) for temperature units. If you get what i'm trying to say
thanks for the feedbacks i've changed how the scrolling works. Now im using a custom button for that.
Looking good providence
I am not sure if you like this idea, but I think it will be more useful if you can add:
- Currency converter
- Currency quick view (to view several currencies at once)
There is an example of a very nice and complete project with source code here:
http://www.codeproject.com/netcf/PocketCurrency.asp
Add option to have automatic currency update as well
[ x ] Update when connected to ActiveSync
[ x ] Automatic update every X hours
hi, well the main idea was to create a finger based Unit conversion program. To add Currency Converter would be a challenge for myself.
Since first of all, Currency changes daily, so there must be a way to update it. Secondly, im still learning how to program by self teaching myself on my free time.
By the way, Here's the latest screenshot of the program.
I fixed the buttons so its easier to use.
unfortunately, this will only work on PDAphones and not on smartphones. Since you'll need to use the touch screen as input method.
Here is an idea, as mentioned by one of the post above, instead of stacking your scroll button up and down, it may save you that more space if you were to stack them left and right.
From what it seems, the < and > , are buttons, which you use it to 'affect' your lists. If you were to (example) sandwish your list in between these two buttons, you would save like another 2 button height. Example.
Currently, you have the layout
Code:
. item1 <
. item2
. item3 >
. item4
if you can just do this (which is possible in VC, not sure about VB), instead
Code:
< .item1 >
.item2
So, instead of 4 item height, you are now only left with 2 items height.
ahh i see..
I tried doing it
< item 1 >
item 2
but i find it harder to navigate, since when you go back you have to drag your finger across the other side of the screen. And while doing that, you are blocking the item list with your finger.
I dont need to save space, i think i got everything in there..
by the way, here's the test i took
then again, if i put them on the sides, it makes easier for those who are left handed as well
The spaces you save, may able you to bloat up the keypad below.. from what it seems, now they are on the 'flat' side of it.
If you think the "left-list-right" is not very finger friendly, you can try the "list-left-right"? That is
.item1 < >
.item2
Hi thanks for the suggestions..
right now here is what i have, and will probably be the final change in the button positioning..
i got big fingers and I can use them without stylus.
Should have a pre-alpha version ready soon. As of now I've done temperatures and acceleration.
Will add more soon

[Q] ListView without scrolling

Is it possible to create a ListView that only displays all of it's content and does not try to be scrollable ?
I need ListViews, because it's the most convenient solution for my app. I have 3 types of content and each has it's own layout style, own context menus and some of them have on click listeners in one case and context menus in other cases. I have a pretty elegant and sexy solution for this, but it only works with ListViews.
The problem is that I want to have all 3 types of content on one screen that will scroll as ONE, but with multiple list views it scrolls as a whole and all lists scroll independently, which makes my app an unusable piece of ****e.
Please only suggest solutions that use list views.
One that I could think of is to create 3 different screens with flip view or maybe some kind of tab view. Or maybe both and let the user choose. What do you think ?
2 things (as I know you're a good programmer, but still kind of "new") LOL
1. Maybe you can @Override the onTouch methods and disable the scroll
2. Don't EVER get so stuck on an interface (or a method, or a piece of code) that you get into a mindset of "It HAS to be this way". Many hours/days I have wasted with this kind of thinking and sometimes, you just have to give-up and start over.
I know you're in a time constraint, but I also find if I leave a problem for a day or two and come back to it, a solution presents itself.
I already put it aside a few days ago, but I'll have to deal with it soon. Actually I just came up with the tab view idea while writing this post and it seems like a good solution (even better than the original with all 3 lists on one screen).
SOLVED
I implemented a tab layout. Like a BAWSSS.

[Q] Creating a "dots" inspired game, need help with a touch concept.

I am trying to develop a game that uses touch between multiple objects. I need to detect when multiple items are touched on one swipe of the finger. The game is similar to "Dots" if you have ever played it. So I need to detect when a dot is pressed and then from there when the finger is dragged to detect the next dot that is touched. I need to keep this going until the finger is lifted. Using dispatchtouchevent and viewgroups is on the right track I think, but that is the furthest I have gotten.
When you are tracking a single touch movement, all the events would be sent to a single view.
So instead of tracking touch events for each Dots, you should track touch events for the common parent ViewGroup.
Lets say you have a frame layout with all the dots places inside.
On ACTION_DOWN
create a Map<Rect, View> for all the dots, where Rect is the position of that view in the viewgroup,
Code:
Rect pos = new Rect(child.getLeft(), child.getTop(), child.getLeft() + child.getWidth(), child.getTop() + child.getHeight());
Essentially you need to create this map only once (and probably again after a relayout).
Then check which Dot was pressed using Rect.contains for each rect,
then on ACTION_MOVE,
Check if the same view was touched, and if not, again check for all the views to see if any other view was touched.

Need Some help with layout in calculator app

i have attached a picture here
1.) how do i set the buttons so that they look uniform throughout different devices (screen size , tablets etc) right now they look different on the emulator and on a device
2.)i also need some help in implementing some code like when i press Shift Button and then press a button it will alternate between functions of that button .. please guide me on how to implement this ?
also is there an easier way to implement a custom grid of buttons rather than using relative layout for all buttons i have looked into gridview but do not know how to customize it ?
please help .. thanks
Make linearlayouts for every row with height wrap and width match. Now for every child button of that linear layout set width as match parent and height wrap_content.and also add another line in all the buttons android:layout_weight="1"
There can be another approach as well. You can use table layout which is easy. You can find guides on Google for it
Sent from my XT1033 using XDA Premium 4 mobile app
arpitkh96 said:
Make linearlayouts for every row with height wrap and width match. Now for every child button of that linear layout set width as match parent and height wrap_content.and also add another line in all the buttons android:layout_weight="1"
There can be another approach as well. You can use table layout which is easy. You can find guides on Google for it
Click to expand...
Click to collapse
Agreed, use a TableLayout (containing multiple TableRows. I suggest reading this doc about creating a table.
umartariq94 said:
1.) how do i set the buttons so that they look uniform throughout different devices (screen size , tablets etc) right now they look different on the emulator and on a device
2.)i also need some help in implementing some code like when i press Shift Button and then press a button it will alternate between functions of that button .. please guide me on how to implement this ?
also is there an easier way to implement a custom grid of buttons rather than using relative layout for all buttons i have looked into gridview but do not know how to customize it ?
Click to expand...
Click to collapse
A totally different option to consider here would be using a KeyboardView instead! That way you won't have to deal with all the buttons (and I think the shift function might be easier as well). As it happens, I wrote a guide on how to implement such a custom keyboard a while ago . You just have to make the KeyboardView a little larger and delete the part where the back key hides it. Be warned though, this class is highly undocumented and it's not guarenteed everything is working the way it should.
Thanks for the replies !

Categories

Resources