2013-03-19 30 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