Need help with a small issue - Java for Android App Development

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.

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

Screen size help

I am attempting to create a layout with two objects of different sizes, one of which will be bigger than the other, about 80% of the screen. The other object will be the remaining 20%. Obviously you cant use percentages in the XML layout to make these objects the right size. Is there a better way to create these objects(they will be some type of view with a background that is a shape drawable) so that i wont have to get the screen resolution from java and do the math in there?
Thanks for the help.. if i get any this time..
Come on some one has to know.. this issue is holding my development up, i cant really go any further until i got this figured out.
I think dips (density independent pixels) are what you want to use. The android dev guide covers them. I can't post a direct link yet because I'm waiting for my account to be verified but a google search for "android dip unit" should get you to the relevant documentation.
Let's say you are using a vertical linear layout. Get screen size, sets smaller objects height to .2* screen height and the others height to fill parent.
Sent from my Nexus One using XDA App
Thanks for the replies. I will retry dips, they didnt seem to come out the same on my G1 as the did on the Evo. But maybe i failed somewhere. If it comes down to it I will just have to use java to resize the screen.

[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.

[Q] How to display data in table!?

Hello Guys, I'm a newbie in app development so help me with this (simple) query.
I have an activity with 4 text box asking for user input (name, place, date, time) . Now how to combine these data into a table in another activity.
PS: I have included exit button in main activity. Is it ok or should I include exit option in action bar menu only? Also what is the java function to exit the app?
Sent from my Xperia Mini using Tapatalk 2
ariftwister said:
Hello Guys, I'm a newbie in app development so help me with this (simple) query.
I have an activity with 4 text box asking for user input (name, place, date, time) . Now how to combine these data into a table in another activity.
PS: I have included exit button in main activity. Is it ok or should I include exit option in action bar menu only? Also what is the java function to exit the app?
Click to expand...
Click to collapse
Hi,
You can easily get a Table with the TableLayout, where in each TableRow you would put two EditTexts. In Android you usually don't need to put an edit button in the layout unless you have a service running or so since there is the back button to easily exit. The Java code to exit would be calling this.finish() from the activity.
SimplicityApks said:
Hi,
You can easily get a Table with the TableLayout, where in each TableRow you would put two EditTexts. In Android you usually don't need to put an edit button in the layout unless you have a service running or so since there is the back button to easily exit. The Java code to exit would be calling this.finish() from the activity.
Click to expand...
Click to collapse
Thanks for your suggestion, but I want all the four editText in a single row. How to do it,? Or is there any detailed tutorial?
Sent from my Xperia Mini using Tapatalk 2
ariftwister said:
Thanks for your suggestion, but I want all the four editText in a single row. How to do it,? Or is there any detailed tutorial?
Click to expand...
Click to collapse
You can find a tutorial on the TableLayout here. But if you just want one row, it's easier to just use a LinearLayout with equal weights for each View. If you want to reuse this layout for another activity, put it in a Fragment!
SimplicityApks said:
You can find a tutorial on the TableLayout here. But if you just want one row, it's easier to just use a LinearLayout with equal weights for each View. If you want to reuse this layout for another activity, put it in a Fragment!
Click to expand...
Click to collapse
Thanks but Actually I'm building an app to keep track all the user's debt. So I want to display the debts in a tabular view. It can be single or multiple varying with every user. So what should I use here?
Also how to place the data got from 4 different edittext as single object into another activity?
Sent from my Xperia Mini using Tapatalk 2
ariftwister said:
Thanks but actually I'm building an app to keep track all the user's debt. So I want to display the debts in a tabular view. It can be single or multiple varying with every user. So what should I use here?
Also how to place the data got from 4 different edittext as single object into another activity?
Click to expand...
Click to collapse
You may want to have a look at the samples of the TableFixHeaders library here to do your Layout. Remember putting it in a separate Fragment in case you want to reuse in another activity.
For data passing you need to put it as extra into the Intent you're starting the second activity with. The data structure you use depends on what you want to do. I recommend dropping everything into a new Bundle and pass that on, that way you can also save/restore when rotating. But if you have only the same data like 4 Strings or 4 doubles you could also directly put it as an array extra with intent.putDoubleArrayExtra or putStringArrayExtra

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