2011-09-05 4 views
0

다음은 db에서 listview로 데이터를 가져 오는 코드입니다.DB의 데이터 일부만 목록보기에 표시하는 방법

private void fillData() { 

    Cursor c = viewDB.fetchAllRows(); 
    startManagingCursor(c); 

    String[] from = new String[] { ViewComplaintsDataDB.KEY_NUMBER, 
      ViewComplaintsDataDB.KEY_DESCRIPTION, 
      ViewComplaintsDataDB.KEY_LOGGEDBY }; //these three are the fields in my db 

    int[] to = new int[] { R.id.com_num, R.id.com_desc , R.id.user }; //these three are the textview id's in my listitem.xml file 

    SimpleCursorAdapter simple = new SimpleCursorAdapter(this, 
      R.layout.listitem, c, from, to); 

    setListAdapter(simple); 

} 

내 DB의 두 번째 열 아래에는 각 행에 많은 데이터가 있습니다. 두 번째 필드의 데이터 만 50 자까지 목록보기로 표시 할 수 있습니까? 도와주세요. 그것에 대해

답변

1

.... 대신 SimpleCursorAdapterArrayAdapter 필요하고 DB에서 보여 어댑터로 설정하는 데 필요한 데이터를 가져옵니다.

<TextView android:text="TextView" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:maxLength="50"></TextView>

+0

감사합니다. 문제가 해결되었습니다 – Santhosh

+0

50 자 이상의 텍스트에 3 개의 점 (...)을 추가하고 싶습니다. 어떻게 추가 할 수 있습니까? – Santhosh

+0

잘 모르겠습니다 만 전화 관련 문제 일 수 있습니다. 나는 에뮬레이터에서 3 개의 점을 얻지 못하므로 각 전화기가 각각의 방식으로이 점을 처리 할 수 ​​있습니다. – colegu

0

당신은 그냥 50에 텍스트 뷰에서 최대 길이의 atribute을 설정할 수

관련 문제