您可以参考此代码,然后您可以获得解决方案......只需根据您的要求申请......
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
RelativeLayout relative = new RelativeLayout(getApplicationContext());
TextView tv1 = new TextView(this);
tv1.setText("Test1");
tv1.setTextColor(Color.GREEN);
tv1.setPadding(3,13,3, 12);
tv1.setId(1);
tv1.setOnClickListener(this);
TextView tv2 = new TextView(this);
tv2.setText("Test2");
tv2.setTextColor(Color.GREEN);
tv2.setPadding(3,13,3,12);
tv2.setId(2);
tv2.setOnClickListener(this);
TextView tv3 = new TextView(this);
tv3.setText("Test3");
tv3.setTextColor(Color.GREEN);
tv3.setPadding(3,13,3, 12);
tv3.setId(3);
tv3.setOnClickListener(this);
TextView tv4 = new TextView(this);
tv4.setText("Test3");
tv4.setTextColor(Color.GREEN);
tv4.setPadding(3,13,3, 12);
tv4.setId(4);
tv4.setOnClickListener(this);
LinearLayout ll = new LinearLayout(this);
ll.addView(tv1);
ll.addView(tv2);
ll.addView(tv3);
ll.addView(tv4);
relative.addView(ll);
actionBar.setCustomView(relative);