Example usage for android.view MenuItem getTitle

List of usage examples for android.view MenuItem getTitle

Introduction

In this page you can find the example usage for android.view MenuItem getTitle.

Prototype

public CharSequence getTitle();

Source Link

Document

Retrieve the current title of the item.

Usage

From source file:org.apache.cordova.plugins.Actionable.java

@Override
public Object onMessage(String id, Object data) {
    if (id.equals("onCreateOptionsMenu") || id.equals("onPrepareOptionsMenu")) {
        mMenu = (Menu) data;//  w w  w.  j  a v  a 2  s .  c  om

        mMenu.clear();
        this.buildMenu();
    } else if (id.equals("onOptionsItemSelected")) {
        MenuItem mi = (MenuItem) data;

        if (mMenuItems.containsKey(mi.getTitle())) {
            Actionable act = mMenuItems.get(mi.getTitle());

            PluginResult res = new PluginResult(PluginResult.Status.OK);
            res.setKeepCallback(true);
            this.webView.sendPluginResult(res, act.getCallbackId());
        } else {
            Log.v("Cambie", "Selected unknown menu item: " + mi.getTitle());
        }
    }

    return null;
}

From source file:com.pepperonas.showcase.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getTitle().equals("About")) {
        new MaterialDialog.Builder(this).title("MaterialDialog library").customView(R.layout.dialog_lib_info)
                .positiveText("OK").positiveColor(R.color.grey_700).icon(R.drawable.ic_launcher)
                .showListener(new MaterialDialog.ShowListener() {
                    @Override//from   w  ww. j  a va2  s.com
                    public void onShow(AlertDialog d) {
                        super.onShow(d);
                        TextView tvLibInfo = (TextView) d.findViewById(R.id.tv_lib_info);
                        tvLibInfo.setText(Html.fromHtml(getString(R.string.web_presentation_info)));
                        tvLibInfo.setMovementMethod(LinkMovementMethod.getInstance());
                    }
                }).show();
    } else if (item.getTitle().equals(Const.HIDE_TOASTS)) {
        mSharedPreferences.edit().putBoolean("SHOW_TOASTS", false).apply();
        item.setTitle(Const.SHOW_TOASTS);
    } else if (item.getTitle().equals(Const.SHOW_TOASTS)) {
        mSharedPreferences.edit().putBoolean("SHOW_TOASTS", true).apply();
        item.setTitle(Const.HIDE_TOASTS);
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.robertcm.romcontrol.project.MainActivity.java

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (mNavMenuItemsIds.contains(id)) {
        int index = mNavMenuItemsIds.indexOf(id);
        loadPrefsFragment(getResources().getStringArray(R.array.nav_menu_xml_file_names)[index]);
        setTitle(item.getTitle().toString());
        mSharedPreferences.edit().putInt(Constants.LAST_FRAGMENT, index).apply();
    } else {/*from  w ww.j  a  v  a  2 s  .c o  m*/
        switch (id) {

        case R.id.themes:
            mFragmentManager.beginTransaction()
                    .add(MyDialogFragment.newInstance(Constants.THEME_DIALOG_REQUEST_CODE), "theme_dialog")
                    .commit();
            break;
        case R.id.changeLog:
            mFragmentManager.beginTransaction()
                    .add(MyDialogFragment.newInstance(Constants.CHANGELOG_DIALOG_REQUEST_CODE), "changelog")
                    .commit();
            break;
        case R.id.about_us:
            startActivity(new Intent(this, AboutActivity.class));
            break;
        case R.id.backup_restore:
            mFragmentManager.beginTransaction()
                    .add(MyDialogFragment.newInstance(Constants.BACKUP_OR_RESTORE_DIALOG_REQUEST_CODE),
                            "backup_restore")
                    .commit();
            break;
        }

    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    assert drawer != null;
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:org.restcomm.android.olympus.MainFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    HashMap<String, String> contact = (HashMap) contactList.get(info.position);

    if (item.getTitle().toString().equals("Update Contact")) {
        mCallbacks.onContactUpdate(contact, AddUserDialogFragment.DIALOG_TYPE_UPDATE_CONTACT);
    }/*  ww  w  .j  a  v a 2 s  . com*/
    if (item.getTitle().toString().equals("Remove Contact")) {
        contactsController.removeContact(contactList, contact.get(CONTACT_KEY), contact.get(CONTACT_VALUE));
        this.listViewAdapter.notifyDataSetChanged();
    }

    return true;
}

From source file:com.eugene.fithealthmaingit.MainActivity.java

private void applyFontToMenuItem(MenuItem mi) {
    Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
    SpannableString mNewTitle = new SpannableString(mi.getTitle());
    mNewTitle.setSpan(new CustomTypefaceSpan("", font), 0, mNewTitle.length(),
            Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    mi.setTitle(mNewTitle);/* w  w w .j  ava  2 s  .  c o m*/
}

From source file:com.truman.showtime.showtime.ui.fragment.TheaterListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterViewCompat.AdapterContextMenuInfo info = (AdapterViewCompat.AdapterContextMenuInfo) item
            .getMenuInfo();/*ww w  . jav  a  2  s .  c  o  m*/
    if (item.getTitle().equals(getString(R.string.directions_theater))) {
        String theaterString = null;
        try {
            theaterString = URLEncoder.encode(mSelectedTheater.address, "UTF-8");
            Uri gmmIntentUri = Uri.parse("geo:0,0?q=" + theaterString);
            // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW
            Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
            // Make the Intent explicit by setting the Google Maps package
            //                mapIntent.setPackage("com.google.android.apps.maps");
            // Attempt to start an activity that can handle the Intent
            if (mapIntent.resolveActivity(mApplicationContext.getPackageManager()) != null) {
                startActivity(mapIntent);
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    } else if (item.getTitle().equals(getString(R.string.share_theater))) {
        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_TEXT, mSelectedTheater.name + "\n" + mSelectedTheater.address + "\n"
                + "http://google.com/movies?near=" + mCity + "&tid=" + mSelectedTheater.id);

        sendIntent.setType("text/plain");
        startActivity(Intent.createChooser(sendIntent, getResources().getString(R.string.share_theater)));
    }
    return super.onContextItemSelected(item);
}

From source file:com.massivcode.androidmusicplayer.activities.MainActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override/*w  ww  .ja  v  a2s  .  co m*/
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    String title = item.getTitle().toString();
    int index = mMemuTitleList.indexOf(title);

    mViewPager.setCurrentItem(index, true);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:com.example.db.messagewall.activity.MainActivity.java

private void setupDrawerContent(NavigationView navigationView) {

    CircleImageView imageView = (CircleImageView) navigationView.findViewById(R.id.account_logo);
    final TextView textView = (TextView) navigationView.findViewById(R.id.account_name);
    final TextView nichen = (TextView) navigationView.findViewById(R.id.account_nichen);
    /*//from  ww  w.  j a  va 2 s .c  o m
    
     */
    AVQuery<AVObject> query = new AVQuery<AVObject>("NiChen");
    query.whereEqualTo("username", AVUser.getCurrentUser().getUsername());
    query.findInBackground(new FindCallback<AVObject>() {
        @Override
        public void done(List<AVObject> list, AVException e) {
            if (e == null) {
                AVObject avObject = (AVObject) list.get(0);
                if (avObject.get("nichen").toString() != null) {
                    textView.setText("?: " + AVUser.getCurrentUser().getUsername());
                    nichen.setText(": " + avObject.get("nichen").toString());
                } else {
                    textView.setText("?: " + AVUser.getCurrentUser().getUsername());
                    nichen.setText(": " + AVUser.getCurrentUser().getUsername());
                }
            } else {
                e.printStackTrace();
            }
        }
    });
    /*
    logo
     */
    SharedPreferences sharedPreferences = this.getSharedPreferences("com.example.db.alife_walllogo",
            Context.MODE_PRIVATE);
    String paper = sharedPreferences.getString("paper_path", "");
    if (paper.equals("")) {
        imageView.setBackgroundResource(R.drawable.head_xiaoqiang_m);
    } else {
        Bitmap bitmap = BitmapFactory.decodeFile(paper);
        imageView.setImageBitmap(bitmap);
    }
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, PersonInfoActivity.class);
            intent.putExtras(bundle);
            startActivity(intent);
        }
    });

    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {

            switch (menuItem.getItemId()) {

            case R.id.nav_home:

                toolbar.setTitle(menuItem.getTitle());
                MessageWallFragment messageWallFeagment = new MessageWallFragment();
                messageWallFeagment.setArguments(bundle);
                fragmentTransaction = getSupportFragmentManager().beginTransaction();
                fragmentTransaction.replace(R.id.container, messageWallFeagment).commit();
                menuItem.setChecked(true);
                mDrawerLayout.closeDrawers();

                break;

            case R.id.nav_partner:

                toolbar.setTitle(menuItem.getTitle());
                MembersFragment membersFragment = new MembersFragment();
                membersFragment.setArguments(bundle);
                fragmentTransaction = getSupportFragmentManager().beginTransaction();
                fragmentTransaction.replace(R.id.container, membersFragment).commit();
                menuItem.setChecked(true);
                mDrawerLayout.closeDrawers();

                break;

            case R.id.nav_messages:

                toolbar.setTitle(menuItem.getTitle());
                WallInfoFragment wallInfoFragment = new WallInfoFragment();
                wallInfoFragment.setArguments(bundle);
                fragmentTransaction = getSupportFragmentManager().beginTransaction();
                fragmentTransaction.replace(R.id.container, wallInfoFragment).commit();
                menuItem.setChecked(true);
                mDrawerLayout.closeDrawers();

                break;

            case R.id.nav_edit:

                toolbar.setTitle(menuItem.getTitle());
                fragmentTransaction = getSupportFragmentManager().beginTransaction();
                EditWallPaperFragment editWallPaperFeagment = new EditWallPaperFragment();
                editWallPaperFeagment.setArguments(bundle);
                fragmentTransaction.replace(R.id.container, editWallPaperFeagment).commit();
                menuItem.setChecked(true);
                mDrawerLayout.closeDrawers();

                break;

            case R.id.nav_add:

                toolbar.setTitle(menuItem.getTitle());
                AskMembersFragment askMembersFragment = new AskMembersFragment();
                askMembersFragment.setArguments(bundle);
                fragmentTransaction = getSupportFragmentManager().beginTransaction();
                fragmentTransaction.replace(R.id.container, askMembersFragment).commit();
                menuItem.setChecked(true);
                mDrawerLayout.closeDrawers();

                break;

            case R.id.nav_alert:

                toolbar.setTitle(menuItem.getTitle());
                startActivity(new Intent(MainActivity.this, AlertWallActivity.class));
                MainActivity.this.finish();
                menuItem.setChecked(true);
                mDrawerLayout.closeDrawers();

                break;

            }
            return true;
        }
    });
}

From source file:com.acrylicgoat.devchat.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (drawerToggle.onOptionsItemSelected(item)) {
        return true;
    }//  w  w w.  j a  v  a  2s  .c om

    String title = (String) item.getTitle();
    if (item.getItemId() == R.id.save) {
        saveNote();
        return true;
    }

    else {
        currentOwner = title;
        //Log.d("MainActivity", "currentOwner = " + currentOwner);
        getOwner(currentOwner);
    }

    return true;
}

From source file:com.github.kanata3249.ffxieq.android.MagicSelectorActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    MagicListView flv = (MagicListView) findViewById(R.id.ListView);

    if (item.getGroupId() == R.id.FilterByType) {
        if (item.getItemId() < 0) {
            mFilterByType = "";
        } else {//from   w  w w  . j  av  a2 s . c  o  m
            mFilterByType = (String) item.getTitle();
        }
        flv.setFilterByType(mFilterByType);
        return true;
    }

    switch (item.getItemId()) {
    case R.id.Remove:
        Intent result = new Intent();

        result.putExtra("From", "MagicSelector");
        result.putExtra("Index", mIndex);
        result.putExtra("Id", -1);
        result.putExtra("SubId", mSubId);
        setResult(RESULT_OK, result);
        finish();
        return true;
    case R.id.Filter:
        showDialog(0);
        return true;
    case R.id.ResetFilter:
        if (flv != null) {
            flv.setFilter("");
        }
        mFilterID = -1;
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}