我在操作栏中有一个按钮,其图标根据布尔值而更改。我想检查使用了哪个可绘制资源。
这是更改图标的代码:
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
MenuItem item = menu.findItem(R.id.menu_favorite);
if(mIsFavorite)
item.setIcon(R.drawable.ab_icon_on);
else
item.setIcon(R.drawable.ab_icon_off);
}
Run Code Online (Sandbox Code Playgroud)
当需要更改图标时,菜单无效:
// request menu update
supportInvalidateOptionsMenu();
Run Code Online (Sandbox Code Playgroud)
最后,我要检查结果的espresso代码:
@Test
public void action_setUnsetFavorite() {
// check favorite off
onView(withImageDrawable(R.drawable.ab_icon_off))
.check(matches(isDisplayed()));
// click favorite button
onView(withId(R.id.menu_favorite))
.perform(click());
// check favorite on
onView(withImageDrawable(R.drawable.ab_icon_on))
.check(matches(isDisplayed()));
Run Code Online (Sandbox Code Playgroud)
请注意,我使用的是此处找到的自定义匹配器。
android android-actionbar android-testing android-support-library android-espresso
我有一个同时具有两个目标的类,我想知道我是否在Watch或iPhone目标上运行它的方法.
请,只是斯威夫特的答案.
我对Swift中的绘图并不是很了解,但我希望创建一个与广场略有不同的应用背景的一部分.请参阅下面的图片,了解我正在尝试制作的内容:
这个想法是,它将位于屏幕的顶部,只不过是背景.它会拉伸到屏幕的一半.然后我会在顶部等处添加图像.我需要在广场底部的点始终位于屏幕中间.
我可以通过代码在Swift中创建这个形状/ UIView吗?如果是这样,怎么样?
或者,将它创建为图像并以此方式执行是否更好?
我有一个名为Chord子类的类UILabel:
import UIKit
class Chord: UILabel {
var numTextLine: Int?
var positionInTextLine: CGFloat?
var tempPosInLine: CGFloat?
init(chordName: String, dLine: DLine, xAxis: CGFloat, posInTextLine: CGFloat) {
// posInLine: CGFloat
let labelSize = chordName.sizeWithAttributes([NSFontAttributeName: UIFont.systemFontOfSize(14.0)])
let labelPositionY = ((dLine.upLine.frame.height) - labelSize.height) / 2
super.init(frame: CGRect(origin: CGPoint(x: xAxis, y: labelPositionY), size: labelSize))
self.numTextLine = dLine.numTextLine
self.positionInTextLine = posInTextLine
self.tempPosInLine = self.positionInTextLine
self.text = chordName
self.font = self.font.fontWithSize(14)
self.textAlignment = NSTextAlignment.Center
self.userInteractionEnabled = true
}
required init?(coder aDecoder: NSCoder) { …Run Code Online (Sandbox Code Playgroud) 我不确定我明白到底IQueryable是什么.
我知道它并没有让我获得所有实体并将约束部分放在内存中,而是将其作为发送到数据库的命令的一部分执行.
如果我弄错了请告诉我,为什么我的存储库函数会返回IQueryable而不是简单List?
我目前正在使用iOS应用程序,没什么大不了的,只是一个简单的预算跟踪器.工作流程如下:将一些新内容编码到app =>将我的iPhone连接到我的Mac =>使用Xcode构建应用程序到我的iPhone 6和我妻子的iPhone 6 plus(所以两个不同的设备!).此时一切正常.
但是,一段时间(有时几天,有时几周),应用程序突然停止在同一时间在两个设备上工作,没有任何铺垫后:我们不更新iOS和不做任何改变的环境下,应用程序刚刚开始这样做:https://s3.amazonaws.com/sized-video-assets-public-v1/wp-content/appadvice-v2-media/2015/07/crash_9b28fddfc26f9f0380f1b0d0b2324018-quarter.gif(但在我的情况下,应用程序无法到达第一个视图,启动后立即崩溃).
最奇怪的是,崩溃的问题开始恰好两个不同的设备在相同的时间,但"没有问题间隔"是绝不相同:有时崩溃后一天开始,有时是两个星期后,我等后重建使用Xcode的设备的应用程序,整个事情重新开始,应用程序工作正常一段时间.
我已经尝试过这些东西来调试这个问题:
这里发生了什么?
我正在为Android项目创建一个库.
该活动在库项目中声明,因为它可以在不同的项目中重用.此活动使用特定于项目的图像.我在主项目中添加了这些图像.
如何从库中的主项目访问资源?
我正在使用 expect 来响应网络服务。但是,我在 Wireshark 中注意到,当我执行以下操作时:
send "mystring\r\n"
Run Code Online (Sandbox Code Playgroud)
它在电线上被翻译成:
"我的字符串\n"
我试过设置stty raw,以及各种组合\r,\n以及从内预计发送ASCII码。Expect 似乎将这些组合中的任何一个转换为\n. 问题是服务器似乎需要一个\r\n才能接受输入。我已经能够确定这一点,因为当我在 expect 中使用“interact”,然后^M从 shell 中键入 a (control-v enter) 时,Wireshark 会看到一串:
"我的字符串\r\n"
通过线路发送,服务器正确处理输入。有没有办法在没有翻译的情况下通过expect正确发送这个组合?
我的应用程序的一部分需要日历访问,这需要从iOS 7开始调用该EKEventStore方法-(void)requestAccessToEntityType:(EKEntityType)entityType completion:(EKEventStoreRequestAccessCompletionHandler)completion.
我添加了请求,如果用户选择允许访问,一切都会顺利运行,但如果用户拒绝或先前拒绝访问,则会出现问题.我添加了一个UIAlertView来通知用户访问是否被拒绝,但是UIAlertView一直需要20-30秒才能显示,并且在此期间完全禁用了UI.调试显示[alertView show]在延迟之前运行,即使它在延迟之后实际上没有显示.
为什么会出现这种延迟?如何将其删除?
[eventStore requestAccessToEntityType:EKEntityTypeEvent
completion:^(BOOL granted, NSError *error) {
if (granted) {
[self createCalendarEvent];
} else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Calendar Access Denied"
message:@"Please enable access in Privacy Settings to use this feature."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}];
Run Code Online (Sandbox Code Playgroud) 我需要获取所有订单详细信息,其中包括所有付款详细信息,客户详细信息和送货详细信息,或说明订单的所有详细信息.为此我在配置文件中使用了一个事件
checkout_onepage_controller_success_action
Run Code Online (Sandbox Code Playgroud)
我的观察者文件中的函数是
public function getorderrealid($observer) {
print_r($observer->getData());
}
Run Code Online (Sandbox Code Playgroud)
函数触发正确,但它返回以下数组
Array
(
[event] => Varien_Event Object
(
[_observers:protected] => Varien_Event_Observer_Collection Object
(
[_observers:protected] => Array
(
)
)
[_data:protected] => Array
(
[order_ids] => Array
(
[0] => 66
)
[name] => checkout_onepage_controller_success_action
)
[_hasDataChanges:protected] =>
[_origData:protected] =>
[_idFieldName:protected] =>
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
[order_ids] => Array
(
[0] => 66
)
)
Run Code Online (Sandbox Code Playgroud)
它只提供订单ID.
请建议我如何获得订单的所有细节.