title: Custom action bar items listener
body: <p>I create custom view for action bar: <strong>action_bar_bets.xml</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:gravity="right"
      android:weightSum="2"
      android:orientation="horizontal" &gt;
  
      &lt;ImageButton
          android:id="@+id/actionBarProfile"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:paddingRight="10dp"
          android:src="@drawable/ic_action_user" /&gt;
  
      &lt;ImageButton
          android:id="@+id/actionBarBets"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:paddingRight="10dp"
          android:src="@drawable/ic_action_betslip" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>here is my menu: <strong>action_bar.xml</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  
  
      &lt;item
          android:id="@+id/mybetsCount"
          android:actionLayout="@layout/action_bar_bets"
          android:showAsAction="always"/&gt;
  
  &lt;/menu&gt;
  </code></pre>
  
  <p>I create action bar in code:</p>
  
  <pre class="lang-java prettyprint-override"><code>ActionBar actionBar = getActionBar();
  actionBar.setDisplayShowTitleEnabled(false);
  actionBar.setDisplayUseLogoEnabled(false);
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setDisplayShowCustomEnabled(true);
  View view = getLayoutInflater().inflate(R.layout.action_bar_bets, null);
  actionBar.setCustomView(view)
  </code></pre>
  
  <p>I tried set OnClickListener to ImageButtons:</p>
  
  <p><em>like this:</em></p>
  
  <pre class="lang-java prettyprint-override"><code>ImageButton profile = (ImageButton) view.findViewById(R.id.actionBarProfile);
  profile.setOnClickListener(new OnClickListener() {
  
      @Override
      public void onClick(View v) {
          Toast.makeText(getApplicationContext(), "Profile", Toast.LENGTH_SHORT).show();
      }
  });
  </code></pre>
  
  <p><em>and like this:</em></p>
  
  <pre class="lang-java prettyprint-override"><code>actionBar.getCustomView().setOnClickListener(new OnClickListener() {
  
      @Override
      public void onClick(View v) {
          switch (v.getId()) {
          case R.id.actionBarProfile:
              Toast.makeText(getApplicationContext(), "Profile", Toast.LENGTH_SHORT).show();
              break;
          default:
              break;
          }
      }
  });
  </code></pre>
  
  <p>But nothing happened</p>
  
  <p>Can you help me to fix this problem?</p>
  
  <p><strong>ADD</strong>
  Also in this class i have <em>ListNavigation</em></p>
  
  <pre class="lang-java prettyprint-override"><code>PackageManager pm = getPackageManager();
  String label;
  try {
      ActivityInfo activityInfo = pm.getActivityInfo(getComponentName(),
              0);
      label = activityInfo.loadLabel(pm).toString();
  } catch (NameNotFoundException e) {
      label = null;
      e.printStackTrace();
  }
  
  String[] navigations = { label, "Sports", "Profile" };
  ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(
          getBaseContext(), R.layout.custom_spinner_title_bar,
          android.R.id.text1, navigations);
  adapter.setDropDownViewResource(R.layout.custom_spinner_title_bar);
  actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
  ActionBar.OnNavigationListener navigationListener = new OnNavigationListener() {
          @Override
      public boolean onNavigationItemSelected(int itemPosition,
              long itemId) {
          switch (itemPosition) {
          case 1:
              Intent intent = new Intent(getApplicationContext(),
                      MainActivity.class);
              startActivity(intent);
              break;
          case 2:
              intent = new Intent(getApplicationContext(),
                      Activity_profile.class);
              startActivity(intent);
              break;
          default:
              break;
          }
          return false;
      }
  };
  actionBar.setListNavigationCallbacks(adapter, navigationListener);
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.action_bar, menu);
      return true;
  }
  </code></pre>