Exemplo n.º 1
0
 @Override
 public boolean onOptionsItemSelected(final MenuItem item) {
   switch (item.getItemId()) {
     case MENU_DELETE_ALL:
       mBookmark.deleteAll();
       return true;
     default:
       break;
   }
   return super.onOptionsItemSelected(item);
 }
Exemplo n.º 2
0
 @Override
 public boolean onContextItemSelected(final MenuItem item) {
   final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
   switch (item.getItemId()) {
     case MENU_DELETE_ONE:
       mBookmark.delete(info.id);
       return true;
     case MENU_EDIT:
       final Object obj = info.targetView.getTag();
       if (obj instanceof ViewHolder) {
         showEditDialog((ViewHolder) obj);
       } else {
         MtkLog.w(TAG, "wrong context item info " + info);
       }
       return true;
     default:
       return super.onContextItemSelected(item);
   }
 }
Exemplo n.º 3
0
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bookmark);

    Bitmap logo = getIntent().getParcelableExtra(KEY_LOGO_BITMAP);
    if (logo != null) {
      getActionBar().setLogo(new BitmapDrawable(getResources(), logo));
    }

    mListView = (ListView) findViewById(android.R.id.list);
    mEmptyView = (TextView) findViewById(android.R.id.empty);

    mBookmark = new BookmarkEnhance(this);
    mCursor = mBookmark.query();
    mAdapter =
        new BookmarkAdapter(this, R.layout.bookmark_item, null, new String[] {}, new int[] {});
    mListView.setEmptyView(mEmptyView);
    mListView.setAdapter(mAdapter);
    mAdapter.changeCursor(mCursor);

    mListView.setOnItemClickListener(this);
    registerForContextMenu(mListView);
  }