2014-03-19 3 views
0

메뉴에서 "android : actionLayout"을 사용하는 데 문제가 있습니다.ActionBar의 사용자 정의 메뉴 항목

저는 이것을 사용하고 이전 프로젝트에서 일 했었지만 지금은 무슨 일이 일어나고 있는지 전혀 모르겠습니다.

은 내가
android:title="@string/menu_notifications" 
android:actionLayout="@layout/menu_notification" 

내 응용 프로그램이 텍스트 변경에 액션 바의 모든 아이콘

을 입력합니다.

나는 많은 것을 시도해 보았습니다. 나는 무슨 일이 일어나고 있는지 전혀 모른다.

조언/아이디어를 부탁드립니다.

EDIT : menu_notification.xml

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="wrap_content" 
android:layout_height="match_parent"> 
<TextView android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:text="TEST" 
android:textSize="20dp" 
android:textColor="#F00" 
/> 
</LinearLayout> 

EDIT 2 등

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 

    getMenuInflater().inflate(R.menu.menu_main, menu); 

    return true; 
} 
+0

예는 OS의 버전이 테스트 무엇 XML –

+0

되어 있습니까? – user1730007

+0

의 @MSS 당신 확인 "menu_notification"XML –

답변

0

변화 menu_notification.xml,

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="TEST" 
    android:textSize="20dp" 
    android:textColor="#F00" 
/> 

및 main.xml에, 다음

 <item 
    android:id="@+id/log_out" 
     android:actionLayout="@layout/menu_notification" 
    android:icon="@drawable/power" 

android:showAsAction="always" 
/> 

,

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 

MenuInflater inflater = getMenuInflater(); 
    inflater.inflate(R.menu.main, menu); 
TextView txtview=(TextView)menu.findItem(R.id.log_out).getActionView(); 
//do remaining stuff here 

}

+0

작동하지 않습니다. 동일한 '알림'텍스트 만 나타납니다. – user1730007

+0

오류가 있습니까 ?? –

+0

오류가 전혀 발생하지 않지만 텍스트 만 다시 표시되는 것은 아닙니다 – user1730007