본문 바로가기

Android Studio

(Android Studio) 리스트뷰 관련 정보 모음

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

리스트뷰 관련


출처 : http://sharepid.tistory.com/951



긁어서 복붙 안된다.


==================


리스트 내용 삭제 하기


출처 : http://tip.daum.net/openknow/59159620


.clear();


==================


리스트 추가 후 갱신 (필수!)


출처 : http://docko.tistory.com/entry/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-ListView%EC%97%90-%EB%8D%B0%EC%9D%B4%ED%84%B0-%EC%B6%94%EA%B0%80-%EB%98%90%EB%8A%94-%EB%B3%80%EA%B2%BD-%EC%8B%9C-%EA%B0%B1%EC%8B%A0Update%ED%95%98%EA%B8%B0


adapter.notifyDataSetChanged();


----------------------------


simple_list_item_2 사용 예제


http://musart.tistory.com/18


SimpleAdapter sap = new SimpleAdapter(this, mlist, android.R.layout.simple_list_item_2, new String[]{"item1", "item2"}, new int[]{android.R.id.text1, android.R.id.text2});

  lv.setAdapter(sap);



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  ArrayAdapter<String> ap = new ArrayAdapter<String>(this,
    android.R.layout.simple_list_item_single_choice, strArray);
  
  // simple adapter test
  ArrayList<HashMap<StringString>> mlist = new ArrayList<HashMap<StringString>> ();
 
  HashMap<StringString> map = new HashMap<StringString> ();
  map.put("item1""musart");
  map.put("item2""10");
  mlist.add(map);
  
  map = new HashMap<StringString> ();
  map.put("item1""sasim");
  map.put("item2""20");
  mlist.add(map);
  map = new HashMap<StringString> ();
  map.put("item1""vincent");
  map.put("item2""30");
  mlist.add(map);
  
  SimpleAdapter sap = new SimpleAdapter(this, mlist, android.R.layout.simple_list_item_2, new String[]{"item1""item2"}, new int[]{android.R.id.text1, android.R.id.text2});
  lv.setAdapter(sap);
cs