isses das ned da scho Oo oder versteh ich an der sache was falsch:
Code
public class XMLTest extends ListActivity {
private static final String TAG = ".MenuActivity";
ArrayList <String>ar = new ArrayList<String>();
ArrayList <String>br = new ArrayList<String>();
ArrayList <String>cr = new ArrayList<String>();
public void machEt(int wert, String partyurl[]) {
Intent intent = new Intent(this, InfoActivity.class);
intent.putExtra("id", partyurl[wert]);
startActivity(intent);
}
private void getWebPageContents(Bundle savedInstanceState)
{
try
{
int location = getIntent().getExtras().getInt("id");
String urlString = "http://www.nontox-le.de/xmlcreate.php?location=" + location;
Log.d(TAG, urlString);
URL url = new URL(urlString);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource(url.openStream()));
doc.getDocumentElement().normalize();
NodeList namen = doc.getElementsByTagName("name");
NodeList daten = doc.getElementsByTagName("datum");
NodeList ids = doc.getElementsByTagName("id");
for (int i = 0; i < namen.getLength(); i++)
{
ar.add(namen.item(i).getTextContent());
Log.d(TAG, ar.get(i));
br.add(daten.item(i).getTextContent());
cr.add(ids.item(i).getTextContent());
}
String a = "";
final String partyurl[] = new String[namen.getLength()];
String String[] = new String[namen.getLength()];
for(int i=0; i < ar.size(); i++)
{
String[i] = ar.get(i) + " am: "+ br.get(i);
if (location == 0) {
partyurl[i] = "http://www.nontox-le.de/nontoxapp.php?lo=0&paid=" + cr.get(i);
}
if (location == 1) {
partyurl[i] = "http://www.nontox-le.de/nontoxapp.php?lo=1&paid=" + cr.get(i);
}
}
this.setListAdapter(new ArrayAdapter<String>(this,R.layout.list, String));
ListView listView = getListView();
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
machEt(position, partyurl);
}
} );
}
catch (Exception e)
{
e.printStackTrace();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWebPageContents(savedInstanceState);
}
}
Alles anzeigen