2013-12-23 3 views
0

나는이 점에서 내가 ... 내가 이런 식으로 시도 사용자 지정 작업 표시 줄을 설정하려면 ... 조각 활동을 확장 활동이 .. 그러나 이것은어떻게 조각 활동에서 ActionBar의 사용자 정의보기를 사용 하시겠습니까?

public class MainActivity extends FragmentActivity 
{ 
bar = getActionBar(); 
      bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); 
      bar.setBackgroundDrawable(new ColorDrawable(Color 
        .parseColor("#0194bf"))); 

      mInflater = LayoutInflater.from(this); 
      mCustomView = mInflater.inflate(R.layout.actionbar_view, null); 
      TextView txtTitle = (TextView) mCustomView 
        .findViewById(R.id.action_title); 
      txtTitle.setText("Recipe List"); 
      txtTitle.setTextSize(22); 
      txtTitle.setTextColor(Color.parseColor("#ffffff")); 
      bar.setCustomView(mCustomView); 
} 

작동하지 않습니다이 내 사용자 지정보기입니다

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/action_title" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center|left" 
    android:textIsSelectable="false" 
    android:paddingLeft="5dip" 
    android:textStyle="bold" 
    android:typeface="serif" /> 
+0

"이 작동하지 않습니다"문제를 설명하는 데 좋은 줄이 아닙니다. logcat을 게시하십시오. 문제를 이해할 수 있도록 – Avijit

+2

bar.setDisplayOptions (ActionBar.DISPLAY_SHOW_CUSTOM); 코드에 이것을 추가하십시오 –

+0

고맙습니다 for answer ... @ Karan –

답변

1

이 줄을 잊지 마십시오 :

actionBar.setDisplayOptions (ActionBar.DISPLAY_SHOW_CUSTOM를);

관련 문제