开发者

Floating popup window - how to implement

开发者 https://www.devze.com 2023-01-14 07:15 出处:网络
I would like to have the following screen in my application: button at the bottom of the screen; when user presses the button, a list with a number of items will appear and user should be able to clic

I would like to have the following screen in my application: button at the bottom of the screen; when user presses the button, a list with a number of items will appear and user should be able to click one of those to start another act开发者_StackOverflowivity. The number of items can be different (depending on some other conditions); the popup is to be adjusted to the button. How would you suggest implementing this?

Thanks a lot.

EDIT: One of the options is PopupWindow. Is there anything better than that?


PopupWindow is great for that. Here's a nice sample http://code.google.com/p/simple-quickactions/.


http://developer.android.com/guide/topics/ui/dialogs.html


You can easily achieve this using a ListView or ListActivity.

or you may also consider using spinners.


How to implement Drag and Drop in android 2.2?

TextView view = new TextView(mActivity);
view.setText("asdasd");
popoup = new PopupWindow(view, 100, 100);
        popoup.setWindowLayoutMode(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

        // set window at position
        popoup.showAtLocation(mActivity.getWindow().getDecorView(), Gravity.CENTER, 100, 100);

popoup.update();

What is usefull to know:

0 setContentView

1 Definetly you must tell popup size ( 0 and 1 is contructor new PopupWindow(view, 100, 100); )

2 an on which location it will be show

3 and call update()

0

精彩评论

暂无评论...
验证码 换一张
取 消