2013-07-15 90 views
0

我正在寻找实现一个对话框,当我点击一个按钮时打开。它应该看起来像在android手机和twitter应用程序中出现的流行的quickaction对话框。但我应该能够将它用作容器,以便我可以添加其他元素,例如按钮,下拉框,文本框等。Android:Quickaction就像对话窗口显示其他组件

当然,它需要用箭头指向按钮弹出按钮调用这个对话框。任何其他类似的例子或者只是我准备实施和使用的准系统描述都应该有帮助。

回答

2

有,你可以用几个例子,这里有一些其中:

http://shardulprabhu.blogspot.ro/2012/08/blog-post_29.html

https://github.com/lorensiuswlt/NewQuickAction

https://github.com/lorensiuswlt/NewQuickAction3D

在我看来,第一个链接例子很容易理解和修改。另一方面,如果你可以创建一个自定义的PopupWindow并添加箭头,这里有一个简单的弹出式示例。

public class MyPopup extends PopupWindow{ 

    public MyPopup (Context context) { 
    super(context); 
    this.context = context; 

公共无效显示(){

if (context == null) 
     return; 

    LayoutInflater layoutInflater = (LayoutInflater) context 
      .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    layout = layoutInflater.inflate(R.layout.mypopup_layout, null); 

    Display display = ((Activity) context).getWindowManager() 
      .getDefaultDisplay(); 
    Point size = new Point(); 
    display.getSize(size); 
    int width = size.x; 
    int height = size.y; 


    setContentView(layout); 
    setWidth(width/4); 
    setHeight(height/2); 
    setFocusable(true); 

    /** 
    * Clear the default translucent background 
    */ 
    setBackgroundDrawable(new BitmapDrawable(context.getResources())); 

    init(); 

    /** 
    * Displaying the pop-up at the specified location, + offsets. 
    */ 
    showAtLocation(layout, Gravity.NO_GRAVITY, xpos, ypos); 

} 


} 
} 

希望你会发现这个有用。 干杯

相关问题