2011-09-13 146 views
2
private DbAdapter_Task task; 
private DbAdapter_Assignment assignment; 
private DbAdapter_User user; 
LinearLayout linear; 
TextView text; 
ListView list; 

@Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     String empid = getIntent().getExtras().getString("EmpID"); 

     assignment = new DbAdapter_Assignment(getBaseContext()); 
     assignment.open(); 

     Cursor cursor = assignment.numOfNewTask(empid); 
     startManagingCursor(cursor); 

     linear = new LinearLayout(this); 
     linear.setOrientation(LinearLayout.VERTICAL); 

     text = new TextView(this); 
     text.setText(Html.fromHtml("<H1>" + "You have " + Integer.toString(cursor.getCount()) + " new assignments." + "</H1>")); 

     list=(ListView)findViewById(R.layout.listlayout); 
     SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.listlayout, cursor,   
       new String[] {"TaskID"}, new int[] { R.id.text}); 
     list.setAdapter(adapter); 

     linear.addView(text); 
     linear.addView(list); 
     setContentView(linear);  
} 

我正在開發蜂窩。我應該如何使用CursorLoader而不是startManagingCursor?蜂窩和startManagingCursor

回答

0

startManagingCursor在蜂窩中已棄用,如果嘗試使用它,很可能會使應用程序崩潰。你最好使用CursorLoader