@Override public boolean onContextItemSelected(MenuItem item) { final int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position; final TOCTree tree = (TOCTree) myAdapter.getItem(position); switch (item.getItemId()) { case PROCESS_TREE_ITEM_ID: myAdapter.runTreeItem(tree); return true; case READ_BOOK_ITEM_ID: myAdapter.openBookText(tree); return true; } return super.onContextItemSelected(item); }
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); // bar = this.getActionBar(); bar.setTitle(R.string.title_toc); bar.setDisplayHomeAsUpEnabled(true); bar.setDisplayShowHomeEnabled(true); bar.setDisplayShowTitleEnabled(true); // final FBReaderApp fbreader = (FBReaderApp) ZLApplication.Instance(); final TOCTree root = fbreader.Model.TOCTree; myAdapter = new TOCAdapter(root); final ZLTextWordCursor cursor = fbreader.BookTextView.getStartCursor(); int index = cursor.getParagraphIndex(); if (cursor.isEndOfParagraph()) { ++index; } TOCTree treeToSelect = fbreader.getCurrentTOCElement(); myAdapter.selectItem(treeToSelect); mySelectedItem = treeToSelect; }