在菜单项中使用actionLayout时,不会调用onOptionsItemSelected方法.我错过了什么,或者它是SherlockActionBar的已知问题?
活动
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.article, menu);
super.onCreateOptionsMenu(menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Log.d(TAG, "onOptionsItemSelected()");
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.menu_item_comment:
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Run Code Online (Sandbox Code Playgroud)
菜单
<item android:id="@+id/menu_item_comment"
android:showAsAction="ifRoom"
android:actionLayout="@layout/action_bar_comment_layout"/>
Run Code Online (Sandbox Code Playgroud)
有没有办法绕过正常行为ViewPager
及其屏幕外页面限制?我的ViewPager
包含四个fragments
,每个包含一个gridview
图像.我遇到的问题是,在创建ViewPager
两个时,fragments
会产生两个图像,这导致同时从catch中下载/获取大约20个图像(每个片段大约10个).是否可以禁用屏幕外页面限制?
我的目标是仅在fragment
选择a时下载图像,或仅在用户悬停图像时下载图像.实现此目的的一种方法是使用onPageSelected
侦听器并设置一个标志,该标志告诉GridViewAdapter
它是否允许下载图像.
我能想到的第二个方法是设置HoverListener
上ImageView
,只有下载的图像onHover
,但听者只在4.0及更高版本.
有没有更好的方法来实现这一目标?
如何在多会话/事务环境中安全地将行插入包含带有(手动)增量键的主复合键的表中.
如何获取最新的递增值column_c
,LAST_INSERT_ID()
不返回所需的值.
我已经调查过SELECT FOR UPDATE ... INSERT
,INSERT INTO SELECT
但无法决定使用哪个.
在事务安全(锁定),隔离级别和性能方面实现这一目标的最佳方法是什么.
更新 - 另一个问题
假设两个事务/会话尝试同时插入相同的column_a,column_b对(示例1,1).我如何能;
按顺序执行插入查询.所述第一插入件(事务1)应导致的1,1,复合键1,和第二(交易2)1,1,2.我需要某种锁定机制
检索插入的column_c值.我可能需要利用变量?
表定义
CREATE TABLE `table` (
`column_a` int(11) unsigned NOT NULL,
`column_b` int(11) unsigned NOT NULL,
`column_c` int(11) unsigned NOT NULL,
PRIMARY KEY (column_a, column_b, column_c)
) ENGINE=InnoDB;
Run Code Online (Sandbox Code Playgroud)
示例数据
+----------+----------+----------+
| column_a | column_b | column_c |
+----------+----------+----------+
| 1 | 1 | 1 |
| 1 | 1 | 2 |
| …
Run Code Online (Sandbox Code Playgroud) 如何将这些类序列化为JSON?
从下面的示例中可以看出,JSON.stringify()
没有序列化对象Cache_Backend_LocalStorage_Tag
内部的列表Cache_Backend_LocalStorage_TagThree
.
我错过了什么?
interface Cache_Backend_LocalStorage_Tag_Interface {
_tag : string;
_keys : string[];
}
class Cache_Backend_LocalStorage_Tag implements Cache_Backend_LocalStorage_Tag_Interface {
public _tag : string;
public _keys : string[];
constructor(tag : string) {
this._tag = tag;
this._keys = [];
}
public add(key : string) : void {
this._keys.push(key);
}
public remove(key : string): boolean {
// Get the index of the key
var index = this._keys.indexOf(key, 0);
// Check if we found the keys index
if (index …
Run Code Online (Sandbox Code Playgroud) 我想在以下字符串中提取/匹配子串/大小"| XS | XL | S | M |" 使用正则表达式.在这种特殊情况下,XS,XL,S和M.
我尝试了以下正则表达式但没有成功.
\|(\w+)\|
Run Code Online (Sandbox Code Playgroud)
比赛:XS,S
(?=.(\w+))
Run Code Online (Sandbox Code Playgroud)
匹配:XS,S,XL,L,S,M
看起来我不能使用箭头函数作为观察者,匿名方法工作正常.我错过了一些关键的东西,为什么背景不同?
ember.debug.js:32096 TypeError: _this3.get is not a function
at .sessionChanged (session.js:77)
at Object.applyStr (ember.debug.js:23331)
at Object.sendEvent (ember.debug.js:16842)
at ObserverSet.flush (ember.debug.js:20171)
at endPropertyChanges (ember.debug.js:20682)
at Object.changeProperties (ember.debug.js:20707)
at Object.setProperties [as default] (ember.debug.js:21786)
at exports.default._emberMetalMixin.Mixin.create.setProperties (ember.debug.js:35465)
at invalidate (session.js:98)
at session.js:42
Run Code Online (Sandbox Code Playgroud)
匿名功能 - 工作.
/**
* Session event observer.
*/
sessionChanged: Ember.observer('user', function() {
// Get the user value
const user = this.get('user');
// Get the session token
const token = this.get('token');
console.log(user, token);
}),
Run Code Online (Sandbox Code Playgroud)
使用箭头功能的观察者方法 - 引发异常.
/**
* Session event …
Run Code Online (Sandbox Code Playgroud)