Search in sources :

Example 1 with MongolMenu

use of net.studymongolian.mongollibrary.MongolMenu in project mongol-library by suragch.

the class MongolMenuActivity method onNoIconsClick.

public void onNoIconsClick(View view) {
    MongolMenu menu = new MongolMenu(this);
    menu.add(new MongolMenuItem("ᠨᠢᠭᠡ"));
    menu.add(new MongolMenuItem("ᠬᠤᠶᠠᠷ"));
    menu.add(new MongolMenuItem("ᠭᠤᠷᠪᠠ"));
    menu.setOnMenuItemClickListener(new MongolMenu.OnMenuItemClickListener() {

        public boolean onMenuItemClick(MongolMenuItem item) {
            MongolToast.makeText(MongolMenuActivity.this, item.getTitle(), MongolToast.LENGTH_SHORT).show();
            return true;
        }
    });
    menu.showAsDropDown(view, 0, 0);
}
Also used : MongolMenu(net.studymongolian.mongollibrary.MongolMenu) MongolMenuItem(net.studymongolian.mongollibrary.MongolMenuItem)

Example 2 with MongolMenu

use of net.studymongolian.mongollibrary.MongolMenu in project mongol-library by suragch.

the class MongolMenuActivity method onShowAtLocationClick.

public void onShowAtLocationClick(View view) {
    MongolMenu menu = getMenu();
    menu.showAtLocation(view, Gravity.CENTER, 0, 0);
}
Also used : MongolMenu(net.studymongolian.mongollibrary.MongolMenu)

Example 3 with MongolMenu

use of net.studymongolian.mongollibrary.MongolMenu in project mongol-library by suragch.

the class MongolMenuActivity method getMenu.

private MongolMenu getMenu() {
    MongolMenu menu = new MongolMenu(this);
    menu.add(new MongolMenuItem("ᠨᠢᠭᠡ", R.drawable.ic_sun));
    menu.add(new MongolMenuItem("ᠬᠤᠶᠠᠷ", R.drawable.ic_moon));
    menu.add(new MongolMenuItem("ᠭᠤᠷᠪᠠ", R.drawable.ic_star));
    menu.setOnMenuItemClickListener(new MongolMenu.OnMenuItemClickListener() {

        public boolean onMenuItemClick(MongolMenuItem item) {
            MongolToast.makeText(MongolMenuActivity.this, item.getTitle(), MongolToast.LENGTH_SHORT).show();
            return true;
        }
    });
    return menu;
}
Also used : MongolMenu(net.studymongolian.mongollibrary.MongolMenu) MongolMenuItem(net.studymongolian.mongollibrary.MongolMenuItem)

Example 4 with MongolMenu

use of net.studymongolian.mongollibrary.MongolMenu in project mongol-library by suragch.

the class MongolEditTextActivity method getMongolEditTextContextMenu.

@Override
public MongolMenu getMongolEditTextContextMenu(MongolEditText met) {
    // This is a demo menu only
    // You will need to implement your own functionality
    // See the MongolEditText source code for examples
    MongolMenu menu = new MongolMenu(this);
    menu.add(new MongolMenuItem("ᠨᠢᠭᠡ", R.drawable.ic_sun));
    menu.add(new MongolMenuItem("ᠬᠤᠶᠠᠷ", R.drawable.ic_moon));
    menu.add(new MongolMenuItem("ᠭᠤᠷᠪᠠ", R.drawable.ic_star));
    menu.setOnMenuItemClickListener(new MongolMenu.OnMenuItemClickListener() {

        public boolean onMenuItemClick(MongolMenuItem item) {
            MongolToast.makeText(MongolEditTextActivity.this, item.getTitle(), MongolToast.LENGTH_SHORT).show();
            return true;
        }
    });
    return menu;
}
Also used : MongolMenu(net.studymongolian.mongollibrary.MongolMenu) MongolMenuItem(net.studymongolian.mongollibrary.MongolMenuItem)

Example 5 with MongolMenu

use of net.studymongolian.mongollibrary.MongolMenu in project mongol-library by suragch.

the class MongolMenuActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch(item.getItemId()) {
        case R.id.action_menu:
            // any view is ok
            View menuButton = findViewById(R.id.action_menu);
            int[] location = new int[2];
            menuButton.getLocationInWindow(location);
            int gravity = Gravity.TOP | Gravity.RIGHT;
            int marginPx = convertDpToPx(MARGIN_DP);
            int yOffset = location[1] + marginPx;
            MongolMenu menu = getMenu();
            menu.showAtLocation(menuButton, gravity, marginPx, yOffset);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : MongolMenu(net.studymongolian.mongollibrary.MongolMenu) View(android.view.View)

Aggregations

MongolMenu (net.studymongolian.mongollibrary.MongolMenu)6 MongolMenuItem (net.studymongolian.mongollibrary.MongolMenuItem)3 View (android.view.View)1