How to handle onContextItemSelected in a multi fragment activity?

前端 未结 11 2087
天命终不由人
天命终不由人 2020-11-29 17:26

I\'m currently trying to adapt my application to use the \"Compatibility Libraries for Android v4\" to provide the benefits of the usage of fragments even to Android 1.6 use

11条回答
  •  眼角桃花
    2020-11-29 18:14

    I found an easier solution than the exposed:

    public boolean onContextItemSelected(MenuItem item) {
        ListView yourList = (ListView) (ListView) getView().findViewById(R.id.yourList);
    
        if (!yourList.hasFocus())
            return false;
    
        switch(item.getItemId()) {
            ...
        }
    }
    

提交回复
热议问题