Marcel Hofmann
- Forum-Beiträge: 3
25.01.2013, 16:01:25 via Website
25.01.2013 16:01:25 via Website
Hallöschen :p
Hoffe dat ik hier richtig bin.. hab folgendes Problem:
Ich möchte gerne mein ListView mit Inhalt füllen. Bis auf weiteres Funktioniert das ohne Probleme, jedoch nur eine Zeile. Wo das Problem liegt, weiß ich nur bedingt. Ich gehe davon aus das einfach kein Item existiert, das gefüllt werden kann. Könnt ihr mir da iwie Rat geben?
ListView.xml
Hoffe echt auf eure Hilfe.. verzweifle schon :/
Hoffe dat ik hier richtig bin.. hab folgendes Problem:
Ich möchte gerne mein ListView mit Inhalt füllen. Bis auf weiteres Funktioniert das ohne Probleme, jedoch nur eine Zeile. Wo das Problem liegt, weiß ich nur bedingt. Ich gehe davon aus das einfach kein Item existiert, das gefüllt werden kann. Könnt ihr mir da iwie Rat geben?
1ListView lv1;
2 lv1=(ListView)findViewById(R.id.listView1);
3
4 List<Map<String, String>> data = new ArrayList<Map<String, String>>();
5 Map<String, String> schoolOV = new HashMap<String, String>(2);
6 String Cat[]={"title","text","title2","text2"};
7 int[] Cat2 = {android.R.id.text1,android.R.id.text2};
8
9 schoolOV.put("title", "Titel Numero 1");
10 schoolOV.put("text", "Text Numero 1");
11 schoolOV.put("title2", "Titel Numero 2");
12 schoolOV.put("text2", "Text Numero 2");
13 data.add(schoolOV);
14
15 try{
16 SimpleAdapter adapter = new SimpleAdapter(this, data, android.R.layout.simple_list_item_2, Cat, Cat2);
17 lv1.setAdapter(adapter);
18 }catch (Exception e){
19 Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
20 }finally{
21 Toast.makeText(this, "Erfolg", Toast.LENGTH_SHORT).show();
22 }
2 lv1=(ListView)findViewById(R.id.listView1);
3
4 List<Map<String, String>> data = new ArrayList<Map<String, String>>();
5 Map<String, String> schoolOV = new HashMap<String, String>(2);
6 String Cat[]={"title","text","title2","text2"};
7 int[] Cat2 = {android.R.id.text1,android.R.id.text2};
8
9 schoolOV.put("title", "Titel Numero 1");
10 schoolOV.put("text", "Text Numero 1");
11 schoolOV.put("title2", "Titel Numero 2");
12 schoolOV.put("text2", "Text Numero 2");
13 data.add(schoolOV);
14
15 try{
16 SimpleAdapter adapter = new SimpleAdapter(this, data, android.R.layout.simple_list_item_2, Cat, Cat2);
17 lv1.setAdapter(adapter);
18 }catch (Exception e){
19 Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
20 }finally{
21 Toast.makeText(this, "Erfolg", Toast.LENGTH_SHORT).show();
22 }
ListView.xml
1<ListView
2 android:id="@+id/listView1"
3 android:layout_width="wrap_content"
4 android:layout_height="wrap_content" >
5 </ListView>
2 android:id="@+id/listView1"
3 android:layout_width="wrap_content"
4 android:layout_height="wrap_content" >
5 </ListView>
Hoffe echt auf eure Hilfe.. verzweifle schon :/
— geändert am 25.01.2013, 16:01:50