Android, How to create option Menu

后端 未结 11 1871
执笔经年
执笔经年 2020-11-27 14:11

Here I tried to make option menu, but menu is not displaying on screen, so please guide me where am I doing mistake...

MenuTest.java

public class Men         


        
11条回答
  •  鱼传尺愫
    2020-11-27 15:05

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        new MenuInflater(this).inflate(R.menu.folderview_options, menu);
        return (super.onCreateOptionsMenu(menu));
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    
        if (item.getItemId() == R.id.locationListRefreshLocations) {
            Cursor temp = helper.getEmployee(active_employeeId);
            String[] matches = new String[1];
            if (temp.moveToFirst()) {
                matches[0] = helper.getEmployerID(temp);
            }
            temp.close();               
            startRosterReceiveBackgroundTask(matches);
        } else if (item.getItemId()==R.id.locationListPrefs) {
            startActivity(new Intent(this, PreferencesUnlockScreen.class));
            return true;
        }           
        return super.onOptionsItemSelected(item);
    }   
    

提交回复
热议问题