ListView Button with link from XML File

fateL

New Member
I'm working on android app that looks like this:(ListView begin) Name - GameDateLink (Button)Name2 - Game2Date2Link2 (Button)(ListView end)that is in a ListView.So a ListView Elemnt is: Name, Game, Date (TextView) and Link(Button)All data come from an XML File So my question: how can I get the link in the button ? like link1 from XML file to button in ListView Element1 and so on. checked already some tutorials but can't get it to work with my code:\[code\]public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listplaceholder); ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>(); String xml = XMLfunctions.getXML(); Document doc = XMLfunctions.XMLfromString(xml); int numResults = XMLfunctions.numResults(doc); if((numResults <= 0)){ Toast.makeText(Main.this, "...", Toast.LENGTH_LONG).show(); finish(); } NodeList nodes = doc.getElementsByTagName("result"); for (int i = 0; i < nodes.getLength(); i++) { HashMap<String, String> map = new HashMap<String, String>(); Element e = (Element)nodes.item(i); if(i==0){ TextView update= (TextView) findViewById(R.id.textView6); update.setText("last Update: "+XMLfunctions.getValue(e, "update")); } else { map.put("name", XMLfunctions.getValue(e, "name")+": " + XMLfunctions.getValue(e, "game") ); map.put("date", XMLfunctions.getValue(e, "date")); mylist.add(map); } } ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main, new String[] { "name", "date" }, new int[] { R.id.item_title, R.id.item_date }); setListAdapter(adapter); final ListView lv = getListView(); lv.setTextFilterEnabled(true); \[/code\]editexample of xml which I parse:\[code\]<result><id>1</id><name>test</name><game>gamename</game><date>27.04</date><link>www.google.com</link></result><result><id>2</id><name>test2</name><game>gamename2</game><date>27.04</date><link>www.google.com</link></result>\[/code\]and the listplaceholder layout\[code\]<ListView android:id="@id/android:list" android:layout_width="fill_parent" android:layout_height="280dp" android:drawSelectorOnTop="false" android:scrollbars="horizontal|vertical"/>\[/code\]and the main layout (layout of the ListView)\[code\]<TableLayout android:layout_width="wrap_content" android:layout_height="fill_parent" > <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/item_title" android:layout_width="146dp" android:layout_height="wrap_content" android:padding="2dp" android:textAppearance="?android:attr/textAppearanceMedium" android:textSize="10dp" /> </TableRow> <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/item_date" android:layout_width="150dp" android:layout_height="wrap_content" android:padding="2dp" android:textAppearance="?android:attr/textAppearanceSmall" android:textSize="10dp" /> </TableRow> <TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content" > <Button android:id="@+id/buttonlink" style="?android:attr/buttonStyleSmall" android:layout_width="10dp" android:layout_height="fill_parent" android:text="Link" /> </TableRow> </TableLayout>\[/code\]
 
Back
Top