首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Dialog源码之文法学习括号直接判断即无if的判断

2012-09-27 
Dialog源码之语法学习括号直接判断即无if的判断Dialog.java类里面,这个函数响应搜索的请求/**???? * This

Dialog源码之语法学习括号直接判断即无if的判断

Dialog.java类里面,这个函数响应搜索的请求
/**
???? * This hook is called when the user signals the desire to start a search.
???? */
??? public boolean onSearchRequested() {
??????? final SearchManager searchManager = (SearchManager) mContext
??????????????? .getSystemService(Context.SEARCH_SERVICE);

??????? // can't start search without an associated activity (e.g a system dialog)
??????? if (!searchManager.hasIdent()) {
??????????? return false;
??????? }

??????? // associate search with owner activity if possible (otherwise it will default to
??????? // global search).
??????? final ComponentName appName = getAssociatedActivity();
??????? final boolean globalSearch = (appName == null);
??????? searchManager.startSearch(null, false, appName, null, globalSearch);
??????? dismiss();
??????? return true;
??? }

?

红色的那句话对我来说比较新奇,是新的语法,我要学习;

?

意思就是说:如果appName是null? 的话就返回true,否则就是false

?

这函数的注释挺有意思,不和Activity关联的Dialog不能打开搜索,呵呵,看来验证了我的一个猜测,就是对话框的制造的种类。

?

?

?

热点排行