/** 初始化控件 */ private void initView() { // make sure the TextView's BufferType is Spannable, see the main.xml textView = (SelectableTextView) findViewById(R.id.main_text); textView.setDefaultSelectionColor(0x40FF00FF); menuView = getLayoutInflater().inflate(R.layout.tpl_select_menu, null); textView.setPopupMenuView(menuView); }
/** 初始化监听事件 */ private void initListener() { this.selectMenuItemListener = new SelectMenuItemListener(this, textView); menuView.findViewById(R.id.select_menu_copy).setOnClickListener(selectMenuItemListener); menuView.findViewById(R.id.select_menu_dict).setOnClickListener(selectMenuItemListener); menuView.findViewById(R.id.select_menu_browser).setOnClickListener(selectMenuItemListener); textView.setOnCursorStateChangedListener( new OnCursorStateChangedListener() { @Override public void onShowCursors(View v) { // TODO Auto-generated method stub // LogUtils.i(TAG, "onShowCursors"); } @Override public void onPositionChanged(View v, int x, int y, int oldx, int oldy) { // TODO Auto-generated method stub // LogUtils.i(TAG, "onPositionChanged"); } @Override public void onHideCursors(View v) { // TODO Auto-generated method stub // LogUtils.i(TAG, "onHideCursors"); } @Override public void onDragStarts(View v) { // TODO Auto-generated method stub // LogUtils.i(TAG, "onDragStarts"); } }); }