ActionBar Sherlock Menu Item OnClick

前端 未结 4 1560
臣服心动
臣服心动 2021-02-04 03:16

I am new to using the Sherlock ActionBar and I have make it run in my app and I have a item in the actionbar to but I don\'t know how to make the item do something when it\'s cl

4条回答
  •  鱼传尺愫
    2021-02-04 03:31

    Try this, it works:

    public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
          com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
          inflater.inflate(R.layout.menu, menu);
    }
    
    public boolean onOptionsItemSelected(MenuItem item) {
          // Handle item selection
          switch (item.getItemId()) {
          case R.id.settings:
              Intent i=new Intent(class1.this, clas2.class);
              startActivity(i);
              return true;
          }
          return false;
    }
    

提交回复
热议问题