Need Some help with layout in calculator app - Java for Android App Development

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 !

Related

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

Smartouch and Zoombar

I am trying to find a way to mess with
HKLM/Software/HTC/SmartTouch/ key in registry, which is supposed to control the zoom bar.
I did some research in several threads in this forum, but all I found was some info (mainly on TD1 threads) on how to make the zoom bar (or scroll wheel in TD1) produce scrolling in apps.
However, what I am interesting in, is ZOOMING within any kind of application. Any idea on how to achieve this? The aforementioned key contains values such as ClassName (which is the app's class, something that is not easy to figure out; any tool on finding out an app's class would be appreciated), WheelCount (which probably is sensitivity), and Mode (which I have no idea what it is).
Anyone could help with this?
I could imagine a few nice things to do with the Zoombar. As I'm missing the arrow keys, it would be great to define a few gestures to use up / down / left / right keys with the zoombar.
e.g.
slide to the right -> right key
slide to the left -> left key
tap on '+' -> up key
tap on '-' -> down key
jcan said:
I am trying to find a way to mess with
HKLM/Software/HTC/SmartTouch/ key in registry, which is supposed to control the zoom bar.
I did some research in several threads in this forum, but all I found was some info (mainly on TD1 threads) on how to make the zoom bar (or scroll wheel in TD1) produce scrolling in apps.
However, what I am interesting in, is ZOOMING within any kind of application. Any idea on how to achieve this? The aforementioned key contains values such as ClassName (which is the app's class, something that is not easy to figure out; any tool on finding out an app's class would be appreciated), WheelCount (which probably is sensitivity), and Mode (which I have no idea what it is).
Anyone could help with this?
Click to expand...
Click to collapse
Hi jcan,
Did you manage to find ways to resolve your question? Kindly share with me please!
Try here:
http://forum.xda-developers.com/showthread.php?t=512614&page=5
Thanks for the link mattan, but I had already tried the Advanced Config solution... It is true that you can add Smartouch capability in active apps from there, but the problem is that I tried some (e.g. GSFinder+), and it worked as a scroll device.
What I am trying to find is a way to make the zoom bar work universally as its name says, i.e. zoom. It would be very nice to be able to zoom in anywhere in the device, like having a magnifying glass. Unfortunately, I haven't found anything yet but I know that the solution is hidden somewhere in the Smartouch reg key... Let's hope some fellow xda member will enlighten us!
and it worked as a scroll device.
Click to expand...
Click to collapse
Actually it's not, it's work like hardware Up/down key. In some case you can redefine action on it (In program settings), for example CorePlayer, or some games.
I think biotouch must be modified for this
jcan said:
Thanks for the link mattan, but I had already tried the Advanced Config solution... It is true that you can add Smartouch capability in active apps from there, but the problem is that I tried some (e.g. GSFinder+), and it worked as a scroll device.
What I am trying to find is a way to make the zoom bar work universally as its name says, i.e. zoom. It would be very nice to be able to zoom in anywhere in the device, like having a magnifying glass. Unfortunately, I haven't found anything yet but I know that the solution is hidden somewhere in the Smartouch reg key... Let's hope some fellow xda member will enlighten us!
Click to expand...
Click to collapse
What you would need to do it actually write an application that zooms the screen in hardware (similar to ctrl + mouse wheel zooming in Mac OSX) and control it with the zoom bar in applications that don't work with the zoom bar at present. I haven't actually used GSFinder+ but if doesn't have some sort of zoom level available to it through a menu function or on screen button then there is no way the zoombar will magically give it (or any other non-zooming program) one.
OK, I get it then... So, if an application does not support zooming, then the zoombar can only be used as a scroll device (or up-down key)...
I guess we will have to settle with that type of use then, until a screen zoom application comes up.
jcan said:
OK, I get it then... So, if an application does not support zooming, then the zoombar can only be used as a scroll device (or up-down key)...
I guess we will have to settle with that type of use then, until a screen zoom application comes up.
Click to expand...
Click to collapse
this is what u want :
criszz said:
this is what u want :
Click to expand...
Click to collapse
What does this cab exactly do, mate?
Read and download here:
http://forum.xda-developers.com/showthread.php?t=406206

[Q] Confused with coding for layout.

Hi there, long time lurker first time poster here!
Slowly getting into android but i really cant get my head around the layouts. I would love to be able to use the AbsoluteLayouts but that isn't a good idea anymore.
Basically after some work i have managed to get a gallery working at the top of the screen. I want my app to look like this in essence: Ok can't post outside links at the moment, fair enough. Think of the android market. Icons to the left and a bit of information for each app next to it and a buy button on the right.
However i have no idea where to start off. Since i have the gallery already i have no idea how i can add things underneath it without screwing anything up.
Can anyone help? Thanks in advance!
Sorry to bump but the issue has changed, I have built an app but would like like the text to be besides the icon. Any chance someone can help? Using a linear layout.
http://img263.imageshack.us/i/sellscreen.jpg/
RED_ said:
Sorry to bump but the issue has changed, I have built an app but would like like the text to be besides the icon. Any chance someone can help? Using a linear layout.
http://img263.imageshack.us/i/sellscreen.jpg/
Click to expand...
Click to collapse
Are you using a List View? Looks like one.
How do you build up your content for the list?
In my view the best solution for your problem would be:
- Use a ListView
- Build your own ListAdapter (drived from BaseAdapter for example)
The Adapter builds the view for each item (or recycles an already built up view, the ListView handles that).
The view for each item would be a horizontal oriented LinearLayout with two items (the image and the text) and the adapter fills the layout with the information of the current item.
For better layout handling I would define the layout for the items in an extra xml file and use the LayoutInflater-Service inside the Adapter (if a view has to be built).
Hope this helps and points into a helpful direction
Devmil
Thanks for replying, managed to find a solution in the end without using ListView. Thought about moving to a RelativeLayout as its more effcient but as my app is very small anyway in the end i've just gone and used nested LinearLayouts with a textview and imageview in each one.
Ridiculously simple when you look back on it.
I was actually going to use this tutorial which does what you explained i think: http://www.anddev.org/iconified_textlist_-_the_making_of-t97.html but it left me with a force close error so that went out the window.

Any tester for virtual keyboard for HD2 ubuntu

hi,
developers had done good job poting ubuntu to htc leo thanks all.
i installed ubuntu on my htc without any and work great but onn such small display i have not found any suitable keyboard so i decide to write a keyboard myself.
keyboard is almost done but my leo was broken last week so i cannot test it.
if sombody can test and give back feedback i can send him and work togather.
asghi said:
hi,
developers had done good job poting ubuntu to htc leo thanks all.
i installed ubuntu on my htc without any and work great but onn such small display i have not found any suitable keyboard so i decide to write a keyboard myself.
keyboard is almost done but my leo was broken last week so i cannot test it.
if sombody can test and give back feedback i can send him and work togather.
Click to expand...
Click to collapse
Sorry to hear about your HD2, have PMed you
file uploaded
if anybody need file can be download from
world-call-trade.com/keyboard
1 download to your home folder of where you want.
2 extrect with command tar -zxf TouchKeyBoard.tar.gz
it will create a folder name TouchKeyBoard, in the folder TouchKeyBoard should be 2 files TouchKeyBoard binary and TouchKeyBoard.png.
3 run from same folder ./TouchKeyBoard
it is written in c and gtk you should not have any problem running on gnome desktop if you have any trouble please let me know i will try to resolv.
there in no F key and some symbols are also missing i can make it on if we need.
my goal is creating a good keyboard as android keybord and after then a functional call and sms system over ubuntu desktop.
ps i am new here so cannot post externel links add http &www befor link
I am using ubuntu 10.10 from http://forum.xda-developers.com/showthread.php?t=1025499 running from sd CM9 android
keys are as follows
qwertyuiop returns 789-=[];' and one other char like ' but I can't it.
asdfghjkl returns abcdefghi
zxcvbnm returns opqrstu
1234567890 returns nothing except 8,9 and 0 returns 0,1 and 2 respectively
Shf button just adds a lowercase m before the above letters.
This could be due to VNC or specific ubuntu build.
will try using Ubuntu 0.3a and mouse.
The key windows are a bit small and should me made bigger within the keyboard window, because the main problem with any onscreen keyboard is the sensitivity of the touchscreen.
A maximise/minimise toggle button would be handy because the actual buttons are tiny.
Also a text window at the top of the keyboard showing the last line of text would be useful (like old typewriter software), then you could maximise the keyboard window to fill the screen without having to check your spelling in the document.
Best of luck with your projects
thanks for testing,
i will try to make change as you suggest and up load as soon as finish.
i used us_en char set may you are using dirfrent i will check also that.
please do a faver if you can some pics from v0.3.
thanks againg.
Have attached screenshot.
All buttons seem to work as they should using 0.3, so must have been different default keyboard in 10.10.
Note the keyboard was "always on top" and the tray buttons were grey
hi,
sorry for late responce i was rewriting everything from scratch.
now it should work on any desktop running xserver and gtk.
i have ported linux to my poor samsung 551 for testing in vnc.
samsung have very low screen resolution 400x240 but keyboard work as expected.
changes:
1. fonts are now more bigger and bold.
2. added configuration file buttons and size are configurable.
3. now there are 2 versions 1 for arm and another for x86.
please let me where i can add min/max button.
out of topic:
is there any port for samsung 551 or samsung 5510?
if no i have ported i will open a new thread if someone need.
Thank you for your work
Keyboard is a big threat in Linux :/
hi,
please test it if you can.
let me know if you need any help.
Hi ashgi, looking good so far.
It still needs a maximise/minimise button. I tried full-screen mode and couldn't get out. There seems to be no Function buttons either, so that I could do ALT F3.
Menu is good idea though
hi Robbie P,
thanks for testing again.
as i asked please give me advice where i can put a min/max button.
last row ramain same on all three pages so we should put a button on last row but there is no space for new button please sombody let me know witch button from last row should be put on another page (a button that less in use) i will try to add another page for missing keys.
but we should finlize first page.
hi,
uploaded 2 new files.
added min/max button.
added F keys please check in Num fkeys.
added missing symbols.
now we have more space on fkey page please let me know if you want add some more keys.
please test new version.
Looks good, m/M button in good position.
The "<" button returns a ">"
There seems to be a small delay between keypress and the colour changing on the button.
Have you thought further on having a toggled text box on the top of the keyboard window showing the last line of typed text. I think this would be a good idea, you could then maximise the keyboard without having to see what you have just typed, and no need to re-arrange windows for best view on such a small screen.
hi,
i am on debian on debian "<" ">" working as expected.
now tested on ubuntu use difrent keysum uploded new file for ubuntu please check if it work.
i will try to add oneline text editor but with toggle key because everybody may not use this feture.
hi,
uploaded new version 0.12
added toggle text box box.
you can access OBD (On Board Display) from Num fkey OBD.
removed ubuntu version added option "dist" in configuration file.
OBD have MAX. 50 words after 50 it will clear display and start from beginning
it have no effect on actual program where you are writing.
Enter key also clear display.
WARNING: OBD display as you type in clear text even PASSWORDS so use on you own risk.
i am not RESPONSIBLE if your girlfriend read you PASSWORDS
Please test and let me know how it works.
Download TouchKeyBoard from http://www.world-call-trade.com/keyboard/
Will it support russian localization?
hi a4necromant,
i am currently working on localization if you can provide translation i will send you header file.
option for switching lang is added to configuration file.
I like the obd
I was thinking text would start on the Right hand side and as letters are typed the words would scroll to the left until they disappeared or reached 50 letters or a return key was pressed. But that might be tricky to code. And others may not like or use it. Possibly changeable font size in obd?Or proportional to window size?
<> is fine now.
Well done again

Need help with a small issue

Hello my team and I are working on a periodic table of elements application for Android we have reached a stopping point due to a issue we're trying to to make the table with buttons and when you click on a certain elements it takes you to another activity where you get details about that specific element I have tried the following layouts and none of them are working:
Linear layout horizontal
Relative layout horizontal
Table layout horizontal ( works to a certain point but after you have about 10 buttons on the page it starts re organizing them we do not want this )
Are we doing something wrong? or are we not done the right thing please let me know
Thank you for any feedback it would be greatly appreciated
Regards
Rapsong11
Sent from my Nexus 4 using xda app-developers app
rapsong11 said:
Hello my team and I are working on a periodic table of elements application for Android we have reached a stopping point due to a issue we're trying to to make the table with buttons and when you click on a certain elements it takes you to another activity where you get details about that specific element I have tried the following layouts and none of them are working:
Linear layout horizontal
Relative layout horizontal
Table layout horizontal ( works to a certain point but after you have about 10 buttons on the page it starts re organizing them we do not want this )
Are we doing something wrong? or are we not done the right thing please let me know
Thank you for any feedback it would be greatly appreciated
Regards
Rapsong11
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
You probably want to use a GridView (or a ListView) and not 250+ Buttons . To do this via xml is not the right way, you should load all the elements in your Activity. Read this on GridViews and use an Adapter to load everything to the Grid.

Categories

Resources