2013-03-19 75 views
2

現在我正在使用微調器,但微調器的外觀是不同的。我想下拉列表中顯示的屏幕列表 enter image description here 請幫如何創建下拉菜單,如截圖所示

+0

這看起來像一個自定義的annimation給我。當你看看微調代碼時,你可能會看到'android.R.layout.simple_spinner_dropdown_item',我認爲它是下拉菜單的佈局。我認爲你可以修改現有的,並根據你的需要使用修改,但是你在這裏展示的不是默認的。 – g00dy 2013-03-19 07:02:54

回答

1

爲什麼要實行這樣的,如果它可以在默認的方式來完成。

這裏還有一個創建快速操作對話框的詳細示例: How to Create QuickAction Dialog in AndroidNewQuickAction

更新:

您可以使用原生PopupMenu對上述顯示在同一個選項。

+1

非常感謝... – hharry 2013-03-19 08:38:01

+0

你能給我一個默認方式的教程鏈接嗎? – 2013-08-29 07:12:37

+1

@ CompaqLE2202x檢查更新的細節。 – 2013-08-29 07:15:16

0

如果你想創建這樣你需要使用對話框..它會顯示爲你想要的。將向下箭頭看作一個按鈕。這些項目顯示爲列表視圖。

public class MainActivity extends Activity { 
     Button dialogButton; 
     Dialog dialog; 
String[] gender={"Male","Female"}; 
    @Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
     { 
     dialogButton=(Button) findViewById(R.id.dialog_button); 
     dialogButton.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 
Toast.makeText(getApplicationContext(), "Button clicked",Toast.LENGTH_SHORT).show(); 
      showDialogMatch(); 
     } 
    }); 


protected void showDialogMatch() { 
    // TODO Auto-generated method stub 
    dialog=new Dialog(this); 

    dialog = new Dialog(this,android.R.style.Theme_Translucent_NoTitleBar); 
    dialog.setContentView(R.layout.match_type_dialog); 
    LayoutParams lp=dialog.getWindow().getAttributes();  
    lp.x=260;lp.y=350;lp.width=280;lp.height=280;lp.gravity=Gravity.BOTTOM | Gravity.LEFT; 
    lp.dimAmount=0;    
    lp.flags=LayoutParams.FLAG_LAYOUT_NO_LIMITS | LayoutParams.FLAG_NOT_TOUCH_MODAL; 
    dialog.show(); 
    ListView lvview=(ListView) dialog.findViewById(R.id.listView1); 
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,gender); 
    lvview.setAdapter(adapter); 

}

和你match_type_dialog XML是這樣

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:background="@drawable/switch_base"> 

<ListView 
    android:id="@+id/listView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 
</ListView> 

+0

你有沒有試過上面的代碼.... – user1835052 2013-03-19 07:43:43

+0

非常感謝... – hharry 2013-03-19 08:38:18

+0

我如何做到這一點,它顯示附近的EditText選擇喜歡的截圖? – 2013-08-29 07:10:00