Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old February 27th, 2011, 02:20 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2009
Posts: 4
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Default Help With Strings

Hello fellow android Programers. I am pretty new to Java and would like to ask for help.
The app I am creating Is a Martial arts info app. As of now I have a splash screen. from that it goes to a list view. in the list view their are pics of the different colored belts in the Martial art. After someone clicks on a belt. they are sent to a Tabs view. 3 different tabs. Syllabus, Video and Etc. instead of creating five different tabs activity's I want to save resources by just creating a string of some sort. So when I click on the belt color I want it to set certain stings to the info of the belt and the sting will be displayed in the tabs view under the specific tab. Maybe im taking this too far. Maybe theirs an easier way. or maybe it would be better to just have a new tabs view activity per belt color.

Advertisements
igorski88 is offline  
Reply With Quote
sponsored links
Old February 27th, 2011, 03:06 PM   #2 (permalink)
Member
 
Join Date: Dec 2010
Location: Aarhus, Denmark
Posts: 136
 
Device(s): SE Xperia X10
Carrier: Not Provided

Thanks: 2
Thanked 22 Times in 22 Posts
Default

well... One way to do it is by using the built in strings.xml to set it up. In that file you can can set up strings and more importantly, string-array's. you can use this to fill out the different values in each belts sub-activities. It goes something like this:

Your list contains a certain number of belts. As a belt is clicked the listview can provide you with the position of the clicked item. Save this position in a static variable in the listview activity - say we call it selectedBeltID.

Then android loads you tabhost activity and shows e.g. Syllabys. In there you have to fill in data about the corresponding belt. To get the right data you then load a systemResource i.e. the right string array - say there is one called syllabus_headers.

In that string-array you input items with data corresponding to the belt id's. So if e.g. the black belt is the first in your listview, then the first item in all the arrays should be about the black belt etc.

Then, when Syllabus needs to fill data into, in this case, its header textview, the text is loaded from the syllabus_headers array, and from the item in place "selectedBeltID" (referencing the static variable set earlier).

This way you can reuse all the same activities for showing data about the different belts and you only have one place to edit and update that data - in your resource files. The same thing goes for stuff like integer arrays and so on.

And if you have some data that is only there in some special cases you can use the "selectedBeltID" as a check to see whether or not to show that data.


Hope this was something of what you were looking for. If not, please specify!
JamTheMan is offline  
Reply With Quote
The Following User Says Thank You to JamTheMan For This Useful Post:
igorski88 (February 27th, 2011)
Old February 27th, 2011, 04:04 PM   #3 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2009
Posts: 4
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Default

I really Like your Idea and I will definitely use it.
The issue I am having is placing the position id into the static variable and then using that id to choose which string array to use. Thank you in advance
igorski88 is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:37 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.