1. Nimm jetzt an unserem Uhans - 3. ADVENT - Gewinnspiel teil - Alle Informationen findest Du hier!

ListView Problem

Dieses Thema im Forum "Android App Entwicklung" wurde erstellt von Garnet, 02.07.2012.

  1. Garnet, 02.07.2012 #1
    Garnet

    Garnet Threadstarter Android-Hilfe.de Mitglied

    Beiträge:
    71
    Erhaltene Danke:
    1
    Registriert seit:
    21.05.2012
    Hallo,
    ich habe eine ListView die nach folgendem Muster aufgebaut ist.

    Code:
    
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public
    [/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ZweispaltigesListViewActivity [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ListActivity [/SIZE]
    [LEFT][SIZE=2]{[/SIZE]
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ArrayList<HashMap<String, String>> [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]myListing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ArrayList<HashMap<String, String>>();[/SIZE]
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] SimpleAdapter [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]saList[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2][COLOR=#3f5fbf][SIZE=2][COLOR=#3f5fbf]/** Called when the activity is first created. */[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f5fbf]
    [/COLOR][/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#646464]
    [/COLOR][/SIZE][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] onCreate(Bundle savedInstanceState) [/SIZE]
    [SIZE=2]{[/SIZE]
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2].onCreate(savedInstanceState);[/SIZE]
    [SIZE=2]setContentView(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]main[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]saList[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]= [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] SimpleAdapter([/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]myListing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE]
    [SIZE=2]R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]two_line_item[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2],[/SIZE]
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] String[] { [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"line1"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"line2"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] },[/SIZE]
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][] { R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]text1[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]text2[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2] } );[/SIZE]
    [SIZE=2]setListAdapter( [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]saList[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE][/LEFT]
     
    [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] i=0; i<=5; i++) {[/SIZE]
    [SIZE=2][U]HashMap[/U] item = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] [U]HashMap[/U]();[/SIZE]
    [SIZE=2][U]item.put([/U][/SIZE][U][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"line1"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], vortragstitel);[/SIZE][/U]
    [SIZE=2][U]item.put([/U][/SIZE][U][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"line2"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]zeit);[/COLOR][/SIZE][/COLOR][/SIZE][/U][/LEFT]
     
    [LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]myListing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].add([U]item[/U]);[/SIZE][/LEFT]
     
    [LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]saList[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].notifyDataSetChanged();[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE][/LEFT]
    [SIZE=2]}[/SIZE]
    
    "vortragstitel" und "zeit" werden dabei aus einer Datenbank eingelesen.
    Jetzt würde ich gerne z.B. den Text der in Zeile 2 an einer bestimmten Listenposition steht in eine Variable speichern. Wie kann ich das machen?

    [/LEFT]
     

Diese Seite empfehlen