2013-09-05 3 views
0

커서로부터리스트 뷰를 만들려고 몇 시간이 걸렸습니다. 정말 작동하지 않습니다. 내가 필요한 데이터로 채워 커서를하고 난 이러한 데이터를 가지고 나는 listactivity에서 확장 활동을 만들어 내가 그 안에 다음 코드를 배치 내 목록보기에 추가해야합니다커서 목록보기 android 2.2+

ListView listv=(ListView)findViewById(R.id.ListView1); 
     Cursor cu;    
     cu=myDbHelper.GetCursor(); 

     ListAdapter adapter =new SimpleCursorAdapter(this,R.layout.rating,cu,new String[]{"Title"}, new int[]{R.id.listText},flag_that_I_dont_know_how_to_use); 
     listv.setAdapter(adapter); 
     myDbHelper.close(); 
     cu.close(); 

I 돈을 '플래그를 사용하는 법을 모르며 simplecursoradapter의 다른 생성자가 사용되지 않으며 두 개의 레이아웃이 있습니다. 하나의 텍스트 레이아웃과 하나의 레이아웃에 listview가 포함 된 등급 레이아웃이 있습니다 ... 그리고 내가 원하는 것을 얻지 못합니다. 빈 페이지 또는 사용 된 플래그에 따라 오류가 발생하는 중 ... 제발 도와주세요 !!

EDIT1 :

은 내가에서 Andriod와 listview1 대체 : ID/목록을 나는 내 코드에 쓴 :

Cursor cu;    
     cu=myDbHelper.GetCursor(); 
     SimpleCursorAdapter adapter =new SimpleCursorAdapter(this,R.layout.rating,cu,new String[]{"Title"}, new int[]{R.id.listText},CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); 
     setListAdapter(adapter); 

하고 나에게 빈 페이지를 가지고;

편집 아무도 아이디어가 있습니까? 또는 누구든지 내가 볼 수있는 샘플이 있고 내 목록보기가 작동하지 않는 이유를 확인합니까? CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER 난 그냥)합니다 (cu.close를 제거하는 데 필요한;

답변

0

시도이다 커서를 닫을 때 페이지가 커서에서 내용을 가져 가기 때문에 화이트 페이지가 있었고 닫히면 그 페이지에는 더 이상 내용이 없습니다! 그리고 확장 된 목록보기를 제거했습니다. 추가 된 활동이 추가 된 필요가 없습니다 ...

0

EDIT1가 플래그를 일이 코드 그래서

ListView listv=(ListView)findViewById(R.id.ListView1); 
       Cursor cu;    
       cu=myDbHelper.GetCursor(); 
       SimpleCursorAdapter adapter =new SimpleCursorAdapter(this,R.layout.rating,cu,new String[]{"Title"}, new int[]{R.id.listText},0); 
       listv.setAdapter(adapter); 
       myDbHelper.close(); 
       cu.close(); 
+0

안녕하세요, 저는 이미 완료했으며 다음과 같은 결과를 얻었습니다 : java.lang.RuntimeException : 귀하의 콘텐츠는 id 속성이 'android .R.id.list '안드로이드에서 미리 정의 된 목록을 사용할 때 빈 페이지가 생겼지 만 ... – User