所以我试图掌握在Android中使用自定义控件.但我的应用程序在尝试创建活动时崩溃了.这是代码:
package com.myApp;
import android.content.Context;
import android.widget.EditText;
import android.view.View;
import android.view.View.OnClickListener;
public class MyEditText extends EditText implements OnClickListener {
public MyEditText(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public void FlashBorder()
{
//do some custom action
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
EditText txt = (EditText) v;
txt.selectAll();
}
}
Run Code Online (Sandbox Code Playgroud)
这是布局xml:
<com.myApp.MyEditText
android:id="@+id/edtTaskName"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
Run Code Online (Sandbox Code Playgroud) 我在这里有点困惑.如果我将变量传递给json_decode,它不起作用:
$stringJSON = $_GET['jsonstring'];
echo $stringJSON;
$stringObject = json_decode($stringJSON);
var_export($stringObject);
Run Code Online (Sandbox Code Playgroud)
第一个回显正确地向我显示了我传递的JSON字符串,例如
{\"Items\":[{\"Name\":\"name\",\"Description\":\"\"],\"Name\":\"Christmas\"}
Run Code Online (Sandbox Code Playgroud)
第二个回显显示NULL.所以我从第一个echo中获取字符串并编写以下代码:
$stringObject = json_decode("{\"Items\":[{\"Name\":\"name\",\"Description\":\"\"],\"Name\":\"Christmas\"}");
var_export ($stringObject);
Run Code Online (Sandbox Code Playgroud)
那你怎么说,它向我展示了正确解码的数组.字符串绝对相同,我甚至保留了转义字符.或者也许他们是问题?
我正在尝试用iPhone拍摄基本照片.我使用以下代码显示相机:
- (BOOL) startCameraControllerFromViewController: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate {
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] == NO)
|| (delegate == nil)
|| (controller == nil))
return NO;
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
// Displays a control that allows the user to choose picture or
// movie capture, if both are available:
cameraUI.mediaTypes =
[UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypeCamera];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, …
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用SOAP记录我的用户.但后来我想使用Analytics API,即REST.但我不希望他们再次输入他们的证书.有没有办法可以使用我已经获得的SOAP sessionId作为REST API的令牌?当我尝试这样做时,我从REST调用中收到了身份验证错误.我错过了什么或者是不可能吗?
NSDate *date = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat setDateFormat:@"MM/dd/yyyy"];
NSLog([@"today is " stringByAppendingString:[dateFormat stringFromDate:date]]);
NSLog([@"firstBirthdayDate is " stringByAppendingString:[dateFormat stringFromDate:firstBirthdayDate]]);
NSLog([@"secondBirthdayDate is " stringByAppendingString:[dateFormat stringFromDate:secondBirthdayDate]]);
if ([firstBirthdayDate isEqualToDate:secondBirthdayDate])
NSLog(@"First date is the same as second date");
if (firstBirthdayDate < date)
NSLog(@"First date is earlier than today");
else
NSLog(@"First date is later than today");
if (secondBirthdayDate < date)
NSLog(@"Second date is earlier than today");
Run Code Online (Sandbox Code Playgroud)
firstBirthdayDate
是01/23/2012secondBirthdayDate
是01/23/2012这是我在日志中得到的:
第一个日期与第二个日期相同
第一次约会比今天晚
第二次约会早于今天
我想我疯了......
我正在使用VSTO开发Excel插件。我刚遇到一个奇怪的问题,如果我尝试从CustomProperties中获取一个值,它将引发COM异常,我也不知道为什么。有人碰到这个吗?这是我要使用的代码:
CustomProperties properties = worksheet.CustomProperties;
properties.Add("name", "value");
Console.Write(properties["name"]); //this crashes COMException. Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
Console.Write(properties[0]); //and this crashes COMException.Exception from HRESULT: 0x800A03EC
Console.Write(properties.Item[0]); //and this also crashes Exception from HRESULT: 0x800A03EC
Console.Write(properties.Item["name"]); //and this crashes as well Type mismatch.
Console.Write(properties.get_Item(0)); //this crashes again HRESULT: 0x800A03EC
Console.Write(properties.get_Item("name"); //and this still crashes Type mismatch.
Run Code Online (Sandbox Code Playgroud)
我不知道如何使用此收藏集。我找到了一种解决方法来读取属性:
Dictionary<string, string> workingProperties = new Dictionary<string, string>();
foreach (dynamic custProp in properties)
workingProperties.Add(custProp.Name, custProp.Value);
string value = workingProperties["name"];// this works
Run Code Online (Sandbox Code Playgroud)
但是,当涉及到更新现有属性时(我很困惑),我需要一种方法来解决该集合中的一个项目,并且没有删除或删除功能来先删除它,然后添加一个具有相同名称的新属性。