2012-01-07 177 views
1

我已經實現用代碼QuickAction菜單和教程中here的Android QuickAction和SQLite數據庫更新

我有我從一個SQLite數據庫,並在單擊記錄時顯示QuickAction菜單記錄填充一個ListView。我不知道該怎麼做是採取使用QuickAction項目選定的記錄動作(當選擇了QuickAction項目在DB例如更新所選的記錄)。

這裏是我的onclick QuickAction聽衆:

quickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() 
{   
    @Override 

    public void onItemClick(QuickAction source, int pos, int actionId) 
    { 

     ActionItem actionItem = quickAction.getActionItem(pos); 

     if (actionId == VIEW) 
     { 
      [view the record] 
     } 
     else if (actionId == UPDATE) 
     { 
      [update a value in the db] 
     } 
     else 
     { 
      [do something else to the record] 
     } 
    } 
    }); 
+0

任何人?任何幫助將不勝感激! – CChandler81 2012-01-17 00:18:35

回答

0

通行證OnItemClick只有立場。要更新記錄,您可以使用putExtra方法:

quickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() 
    {    
    @Override 
    public  void onItemClick(int pos) 
    { 
     if (pos == 0) 
      { //View item selected         
     Toast.makeText(YourCurrentActivity.this, "View item selected", 
       Toast.LENGTH_SHORT).show(); 
     } 
     else if (pos == 1) 
     { //Update item selected 
       Toast.makeText(YourCurrentActivity.this, "Update item selected", 
         Toast.LENGTH_SHORT).show(); 
     } 
     else if (pos == 2) 
     { //Other item selected 
       Toast.makeText(YourCurrentActivity.this, "Other item selected", 
         Toast.LENGTH_SHORT).show(); 
    }        
    }        
});