How to retrieve data from xml database in Android and display it in activity textview?



I am new in Android and still learning. This is my first project so far. I created sport app with Men's and Women's sports. Now I want to display all events from my xml database when I click on certain sport. Example: If I click on Men's Basketball I want to see all Basketball events. Then with clicking on the one of the events to display type of event, time, result(if it's previous),date and site. Here is my xml database file:



this Main (id=831963041952)
groupedFeeds ArrayList (id=831963624640)
array Object[12] (id=831963625992)
[0] GroupedFeed (id=831963625872)
category "Women's Golf" (id=831963458528)
feeds ArrayList (id=831963625896)
array Object[12] (id=831963625920)
[0] RssMsg (id=831963457808)
date "2014-09-20" (id=831963460672)
dateRevised "2014-09-22 12:01:48" (id=831963462600)
eventResult "4th of 8" (id=831963463272)
eventType "Women's Golf" (id=831963458528)
location "Galena, Ill. (Eagle Ridge South G.C.)" (id=831963461976)
name "Clarke Invitational" (id=831963459184)
note null
time "10:00:00" (id=831963461320)
[1] RssMsg (id=831963483088)
date "2014-09-21" (id=831963485616)
dateRevised "2014-09-21 22:35:44" (id=831963487424)
eventResult "3rd of 8" (id=831963488064)
eventType "Women's Golf" (id=831963483680)
location "Galena, Ill. (Eagle Ridge South G.C.)" (id=831963486848)
name "Clarke Invitational 1" (id=831963633048)
note null
time "11:00:00" (id=831963486232)
[2] RssMsg (id=831963523952)
[3] RssMsg (id=831963611400)
[4] RssMsg (id=831963621752)
...
modCount 5
size 5
[1] GroupedFeed (id=831963627192)
category "Volleyball" (id=831963464056)
feeds ArrayList (id=831963627216)
[2] GroupedFeed (id=831963627344)
category "Men's Soccer" (id=831963468880)
feeds ArrayList (id=831963627368)
[3] GroupedFeed (id=831963627496)
...
modCount 11
size 11
loader RSSLoader (id=831963042664)
aMan AssetManager (id=831962936928)


Now I have to create for loop and implement each sport at the right place. I tried few different options but did not work. If someone can help I would appreciate that! Here is my Main method:



// Here I wanted to create my for loop but that did not work
// GroupedFeed findFeed(String locateSport)


public boolean onChildClick(ExpandableListView parent,
android.view.View v, int groupPosition, int childPosition,
long id) {
switch (groupPosition)
{
case 0:
switch (childPosition)
{
case 0:
// gfResult = findFeed("Men's Baseball");
Baseball(); // pass gfResult
break;
case 1:
MensBasketball();
break;
}
return false;
}

private void Baseball() {
Intent myIntent = new Intent(MainActivity.this, Baseball.class);
startActivity(myIntent);
}

private void MensBasketball() {
Intent myIntent = new Intent(MainActivity.this, MensBasketball.class);
startActivity(myIntent);
}


I did not put entire code because is the same just for different sport.


No comments:

Post a Comment