M
MrRAP
Neues Mitglied
- 0
hi,
komme von c# und bin eine "newbee" auf android. google schon seit tagen und bin mir nicht sicher ob meine idee überhaupt funktioniert.
folgendes problem:
ich lade über ein php-skript meine xml-datei und bekomme einen xml-string als "response". funktioniert alles einwandfrei.
jetzt habe ich den xml-string in einer variable (natürlich ist der string schon auf android-layout formartiert --> d.h. füge ich den quellcode in meine activity_main.xml ein, wird auch alles richtig angezeigt).
wie kann ich jetzt diesen string direkt auf meine activity zuweisen (also z.b. mit setContentView)?
habe schon einiges mit xml-parser herumprobier, z.b.:
komme von c# und bin eine "newbee" auf android. google schon seit tagen und bin mir nicht sicher ob meine idee überhaupt funktioniert.
folgendes problem:
ich lade über ein php-skript meine xml-datei und bekomme einen xml-string als "response". funktioniert alles einwandfrei.
jetzt habe ich den xml-string in einer variable (natürlich ist der string schon auf android-layout formartiert --> d.h. füge ich den quellcode in meine activity_main.xml ein, wird auch alles richtig angezeigt).
wie kann ich jetzt diesen string direkt auf meine activity zuweisen (also z.b. mit setContentView)?
habe schon einiges mit xml-parser herumprobier, z.b.:
Code:
[SIZE=2]DefaultHttpClient hc = [/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] DefaultHttpClient(); [/SIZE]
[SIZE=2]ResponseHandler <String> res = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] BasicResponseHandler(); [/SIZE]
[LEFT][SIZE=2]HttpPost postMethod = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] HttpPost([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff][URL]http://.../get_menu.php[/URL][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]String response=hc.execute(postMethod,res); [/SIZE]
[SIZE=2]//^^^^bis hier hin ist alles klar^^^^[/SIZE][/LEFT]
[/LEFT]
[LEFT][SIZE=2]XmlPullParserFactory factory = XmlPullParserFactory.[I]newInstance[/I]();[/SIZE]
[LEFT][SIZE=2]factory.setNamespaceAware([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
[SIZE=2]XmlPullParser xpp = factory.newPullParser();[/SIZE][/LEFT]
[/LEFT]
[LEFT][SIZE=2]xpp.setInput( [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] StringReader ( response ) );[/SIZE][/LEFT]
[LEFT][SIZE=2]LayoutInflater inflater = getLayoutInflater();[/SIZE]
[LEFT][SIZE=2]View view = inflater.inflate(xpp, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE][/LEFT]
[/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2].setContentView(view);[/SIZE][/LEFT]
was mache ich falsch bzw. wie gehe ich das besser an oder ist das überhaupt möglich?
vielen dank im voraus.
vielen dank im voraus.
lg