LayoutInflater attention points used and the use of PopupWindow

2011-05-26  来源:本站原创  分类:Mobile  人气:96 

LayoutInflater:

mLayout = (LinearLayout)LayoutInflater.from(context).inflate(resLayoutId, null);

---> Which resLayoutId layout style for the id, attention must be layout-level: R.layout. Name

PopupWindow use:

PopupWindow was blocking the dialog box, and only in the external thread or do exit operation Caixing PopupWindow itself. PopupWindow Layout made entirely dependent on the appearance of the development in common, PopupWindow should always be mixed with AlertDialog.

public class MenuActivity extends Activity {

        private static final String TAG = "MenuActivity";

        MenuPopupWindow menu1;
        View lt;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        lt = findViewById(R.id.ll_root);
        menu1 = new MenuPopupWindow(this, R.layout.menu);

    }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
                menu.add(1,100,1,"menu");
                Log.e(TAG, "======onCreateOptionsMenu=======");
                return super.onCreateOptionsMenu(menu);
        }

        @Override
        public boolean onMenuOpened(int featureId, Menu menu) {
                Log.e(TAG, "======onMenuOpened=======");
                /*if(menu1!= null){
                        if(menu1.isShowing()){
                                menu1.dismiss();
                        }else{*/
                //menu1.showAtLocation(lt, Gravity.BOTTOM, 0, 0);
                //      }
                //}

                return super.onMenuOpened(featureId, menu);
        }

        @Override
        public boolean onPrepareOptionsMenu(Menu menu) {
                Log.e(TAG, "======onPrepareOptionsMenu=======");
                menu1.showAtLocation(lt, Gravity.BOTTOM, 0, 0);
                return false;//super.onPrepareOptionsMenu(menu);
        }

        class MenuPopupWindow extends PopupWindow{

                LinearLayout mLayout;

                public MenuPopupWindow(Context context, int resLayoutId) {
                        super(context);
                        mLayout = (LinearLayout)LayoutInflater.from(context).inflate(resLayoutId, null);
                        this.setContentView(mLayout);
                        this.setWidth(LayoutParams.FILL_PARENT);
                        this.setHeight(LayoutParams.WRAP_CONTENT);
                        this.setFocusable(true);
                        ///  Set the popupWindow of a transparent background color 

                }
        }

Note that in, onPrepareOptionsMenu this method return value is false, the implementation of the order of menu is:

onPrepareOptionsMenu ----- true ----> onMenuOpened ---- true ----> drawmenu

相关文章
  • LayoutInflater attention points used and the use of PopupWindow 2011-05-26

    LayoutInflater: mLayout = (LinearLayout)LayoutInflater.from(context).inflate(resLayoutId, null); ---> Which resLayoutId layout style for the id, attention must be layout-level: R.layout. Name PopupWindow use: PopupWindow was blocking the dialog box,

  • Android NDK development of OpenGL ES 2.0 Some attention points 2010-08-20

    Wow Android is a good system, especially Android NDK r3 came out, you can use the OpenGL ES 2.0. Himself tried the code with an OpenGL ES 2.0 NDK procedures, however, when you compile a lot of mistakes. Figure, full screen are undefined reference to

  • Common Errors in SQL Server into Excel, and attention points 2010-11-17

    1, excel the first line of field names and field names must correspond to the database, import the "Select the table and source view" steps should pay attention to the "Edit" option is already listed in the EXCEL and the corresponding

  • Oracle table space with a uniform extent size of the attention points 2011-04-28

    Today, doing the test with EXTENT MANAGEMENT LOCAL UNIFORM management encountered problems seem rather strange, so some research. First, create three tablespaces, pay attention to its initial size and the UNIFORM SIZE. SQL> create tablespace testbloc

  • IMAP using PHP to access some of the attention points 2010-03-03

    1. Net_IMap package on Pear inside this package, there have BUG, get out there from 1.0.3 to 1.1.0, and has a new BUG Relative or recommendation 1.0.3 2. On the IMAP command to take the message of the framework can be BODYSTRUCTURE There is a problem

  • Oracle common statistic function and attention points 2010-04-16

    oracle in the over () window function <br /> understanding of the analysis window function specifies the work function data window size, the data window size may be changes with the line changes, for example as follows: over (order by salary) in acc

  • Points to note in the modifier java 2010-11-12

    abstract of the attention points: abstract modifier can be used with modified method of abstract classes and members of the modified class represents an abstract class, abstract class in the inheritance tree of the abstraction layer, the abstract cla

  • Online Update web program implementation 2010-03-29

    To talk about the former realization of a web program's online update to give people who had not been achieved to provide a little thinking, this is my implementation of a project, perhaps not a good way, but it achieved the basic needs. The company

  • Tortoise SVN client to use 2010-03-29

    A lot of friends all prefer to use Tortoise SVN, Tortoise SVN has a lot of little things a lot of similar software can not be Bimei, now let's take a look at Tortoise SVN client, the basic use 1. Export, and check out export download the source code

  • JDK's URLConnection Summary 2008-07-29

    (Reproduced in: blog java: http://www.blogjava.net/xinwuhen/archive/2008/03/01/183159.html) For JDK's URLConnection connection Servlet question, on-line there though in relation to this, but it only shows one or several issues, based on the way to so

  • JDK's URLConnection arguments detailed 2010-03-24

    Their own learning to use, reproduced the article http://blog.chinaunix.net/u3/109937/showart_2162626.html For JDK's URLConnection connection Servlet question, on-line there though in relation to this, but it only shows one or several issues, based o

  • Dyeing production management 2010-02-18

    Keywords: As a dyed enterprises, on the stain, "a success" with the most profound experience, although rapid progress is now dyeing equipment, package dyeing technology has matured, many experts and scholars for the dyeing of summary many exampl

  • eclipse.ini Parameter Configuration 2010-06-07

    -Vmargs parameters: a set JVM parameters. JVM-Xms set initial allocation of memory, the default is the physical memory of 1 / 64 -Xmx to set the maximum JVM memory allocated, the default is the physical memory of 1 / 4 -Vm set the virtual machine -XX

  • Single load balancing of multiple Squid 2010-06-23

    Now, in a large traffic site, squid reverse proxy caching has become a commonly used technique. However, we all know, squid does not support SMP, so the original is not supported on a single server, the same port (for example, to reverse proxy web mu

  • Reading new.delete. Point to a continuous space pointer. Array. Space release. Space applications [C + +] [Memory Management] Impression 2010-08-13

    1. Use new and delete operator, the rate of change when the PF Ctrl + Alt + Del to enter the Task Manager, performance, run the following code, and observe the PF rate changes. Known, new operator to increase PF rate, delete to restore the PF rate. N

  • Use of Partitioned Outer Join to achieve thickening Report 2010-09-06

    Use of Partitioned Outer Join to achieve thickening Report Analysis: Ding (dingjun123) Background: In the database table, the stored data is often sparse data (sparse data), rather than the dense data (dense data). First to look at what is sparse dat

  • JDBC learning summary 2010-09-18

    JDBC part of the terminal into mysql: mysql-u root Enter the terminal into the oracle: telnet 192.168.0.23 then sqlplus openlab/open123 MySQL frequently used commands: show databases; use tableName; show tables; An overview of JDBC JDBC from the phys

  • xp boot speed optimization 2010-11-13

    By the following methods to optimize (WinXP), to speed up system speed: 1, killing the virus with anti-virus software, ensure that the system for viruses. Antivirus software download 2, run the Disk Defragmenter finishing disk, eliminating disk fragm

  • Optimization of C drive 2010-12-08

    Mainly talk about the Windows operating system disk space in the C case, what specific measures we can to increase the C drive space. 1. Open "My Computer" - "Tools" - "Folder Options" - "View" - in the "Show h

  • HOW TO PARSE AN EMAIL USING THE JAVAMAIL API 2010-12-11

    E-mail with the JavaMail API content analysis of some related issues, write very well. Original Address: http://techforum4u.com/content.php/177-HOW-TO-PARSE-AN-EMAIL-USING-THE-JAVAMAIL-API Article Origin Location: http://techforum4u.com/content.php/1