2012-09-09 2 views
0

항목을 클릭 한 후 메뉴 만들기 : enter image description here분할 작업 표시 줄 나는 이런 식으로 뭔가를 만들

지금까지 내가 무슨 짓을했는지 :

public boolean onOptionsItemSelected(MenuItem item) { 
    switch (item.getItemId()) { 
    case R.id.menu_layer: 
     //I want to create my menu here 
     break; 

    case R.id.menu_direction: 

     break; 

    default: 
     break; 
    } 
    return (true); 
}` 

그것은 내 주요 menu.xml입니다 :

:
<menu xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:id="@+id/menu_layer" 
     android:icon="@drawable/ic_action_search" 
     android:title="@string/menu_layers" 
     android:showAsAction="ifRoom|withText" /> 
<item android:id="@+id/menu_direction" 
     android:icon="@drawable/ic_action_search" 
     android:title="@string/menu_directions" 
     android:showAsAction="ifRoom|withText" /> 
</menu> 

& 내가 menu_layer를 클릭 한 후 생성 할 메뉴입니다

아무도 도와 줄 수 있습니까? 미리 감사드립니다.

답변

1

지도 앱에서 볼 수있는 것은 맞춤 대화입니다. 정말로 자신 만의 완전 맞춤형 대화 상자를 만들 수 있습니다. 레이아웃 (예 : custom_dialog.xml)을 작성하십시오.

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
> 
    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Hey!" 
    /> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
    /> 
</LinearLayout> 

이 파일을 프로젝트/레이아웃 폴더에 넣으십시오.

이 코드를 표시 할 대화 상자를 만드는 Activity의 onCreateDialog (int)에 넣으십시오.

Dialog dialog = new Dialog(getApplicationContext()); 
dialog.setContentView(R.layout.custom_dialog); 

[... misc. initialization] 

는 간단히 말해서 나는 당신의 질문에 대답하려했지만이 가능한 소스 많이하고 Android's API Guide 완전히 대화 상자를 생성하고 사용자 정의하는 방법을 설명합니다.

관련 문제