Listview clickable of a list after xml parsing

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Listview clickable of a list after xml parsing

Postby 8kikko2 » Sat Jan 24, 2009 5:30 pm

Hi everyone I'm new but I read a lot of posts.. I have to convert my java app in android.. it is simple but I want to create a selectable Listview of my Fairs..

here my code :

public class DOMElements{
private static List<FairComponents> faircontainer=new ArrayList<FairComponents>();
private final static String xmlFileName = "c:/simplestfairs.xml";





static public void main(String[] arg){


try {
// BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
// System.out.print("Enter XML File name: ");
File file = new File(xmlFileName);

if(file.exists()){
// Create a factory
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// Use the factory to create a builder
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(xmlFileName);
Element docEle = doc.getDocumentElement();
// Get a list of all elements in the document





NodeList list = docEle.getElementsByTagName("fairname");
System.out.println("XML Elements: ");

for (int i=0; i<list.getLength(); i++) {
// Get element
Element element = (Element)list.item(i);
FairComponents fairc=new FairComponents();
faircontainer.add(fairc);
System.out.println(element.getNodeName());
fairc.setFairname(element.getFirstChild().getNodeValue());
System.out.println(fairc.getFairname());
// substring(20, 20)
}

NodeList list1 = docEle.getElementsByTagName("description");

for (int i=0; i<list1.getLength(); i++) {
// Get element
Element element = (Element)list1.item(i);
FairComponents fairc=faircontainer.get(i);
System.out.println(element.getNodeName());
fairc.setDescription(element.getFirstChild().getNodeValue());
System.out.println(fairc.getDescription().substring(0, 20));
// substring(0, 20)
}


NodeList list2 = docEle.getElementsByTagName("start");


for (int i=0; i<list2.getLength(); i++) {
// Get element
Element element = (Element)list2.item(i);
FairComponents fairc=faircontainer.get(i);
System.out.println(element.getNodeName());
fairc.setStart(element.getFirstChild().getNodeValue());
System.out.println(fairc.getStart());
// substring(20, 20)
}
}

else{
System.out.print("File not found!");
}
}
catch (Exception e) {
System.exit(1);
}
}




}[syntax="java"]

----------------
fairname
description <image>
start
--------------
----------------
fairname
description <image>
start
--------------
----------------
fairname
description <image>
start
--------------
This is the layout that I want ,clickble to go to the single description of one fair...

any ideas?
thank....
8kikko2
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Jan 08, 2009 1:41 am

Top

Postby darolla » Sun Jan 25, 2009 2:40 pm

hi,

maybe you should take a closer look to the api demos esp list (there are 14 examples) in the android sdk / samples folder...

after you managed to create your own listview you can use your code to help yourself ;)

greetings,
darolla
User avatar
darolla
Master Developer
Master Developer
 
Posts: 273
Joined: Thu Sep 25, 2008 5:16 pm
Location: Dortmund, Germany

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests