Expandable Listvie Items in Asynctask hinzufügen

C

chazon

Neues Mitglied
0
Hallo Leute

Ich versuche gerade in in einem expandable Listview
Items hinzuzufügen. Was ich zerst probiert habe ist folgendes :

Code:
[SIZE=2]
 [/SIZE]  [LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]loader[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]= [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] DbTask();[/SIZE][/LEFT]
[SIZE=2]
 [/SIZE]  [LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]loader[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].executeOnExecutor(AsyncTask.[/SIZE][B][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]THREAD_POOL_EXECUTOR[/COLOR][/SIZE][/COLOR][/SIZE][/I][/B][SIZE=2]);[/SIZE][/LEFT]
[SIZE=2]
 [/SIZE]  [LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// get the [U]listview[/U][/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
 [LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]expListView[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = (ExpandableListView) findViewById(R.id.[/SIZE][B][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]expandableListView1[/COLOR][/SIZE][/COLOR][/SIZE][/I][/B][SIZE=2]);[/SIZE][/LEFT]
[SIZE=2]
   [/SIZE] [LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// preparing list data[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [LEFT]prepareListData();[/LEFT]
[/SIZE] [LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]listAdapter[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ExpandableListAdapter([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]listDataHeader[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]listDataChild[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE][/LEFT]
[SIZE=2]
  [/SIZE]  [LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// setting list adapter[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]expListView[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setAdapter([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]listAdapter[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
 [/SIZE]
Zuerst werden die Daten über einen Webservice (Asynctask) geholt.
Anschließend sollen die Daten in das expandable ListView eingefügt werden.
Im obigen Beispiel funktioniert das nicht .

Wenn ich nun das View innerhalb DBTask füllen möchte muss ich das in einem UIThread machen . Am besten hier:

Code:
[SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]
   [LEFT]@Override[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE] [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]protected[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onPostExecute(Void [/SIZE][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]result[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) {[/SIZE][/LEFT]
[SIZE=2]
    [LEFT]Runnable [/LEFT]
[/SIZE] [LEFT][U][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]addMessage[/COLOR][/SIZE][/COLOR][/SIZE][/U][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Runnable() {[/SIZE][/LEFT]
[SIZE=2]
 [/SIZE]  [LEFT][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
[SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]
[/COLOR][/SIZE][/COLOR][/SIZE] [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] run() {[/SIZE][/LEFT]
[SIZE=2]
     [LEFT]}[/LEFT]
  [LEFT]prepareListData();[/LEFT]
 [LEFT]};[/LEFT]
 [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2].onPostExecute([/SIZE][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]result[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
 [/SIZE]

aber das gibt mir auch ein leeres Listview.​
Ich denke ich habe da einen Denkfehler.​
Für Eure Hilfe wäre ich sehr dankbar..​

Danke und Gruß Chazon​
 

Ähnliche Themen

J
Antworten
5
Aufrufe
930
swa00
swa00
D
Antworten
23
Aufrufe
2.557
Data2006
D
M
Antworten
8
Aufrufe
1.685
swa00
swa00
Zurück
Oben Unten