我在JAVA中有一个ENUM我想序列化,所以当我从代码中的任何地方调用它时,我得到名称的小写表示.
假设我有以下枚举:
public enum Status {
DRAFT, PENDING, COMPLETE;
}
println ("Status=" + Status.DRAFT);
Run Code Online (Sandbox Code Playgroud)
我想得到以下内容:
Status=draft
Run Code Online (Sandbox Code Playgroud)
[注意]:我想以大写形式使用枚举常量,并在请求值时获取小写表示.
noobie question ..检查NSArray或NSMutableArray的索引是否存在的最佳方法是什么.我到处搜索都没有用!
这是我尝试过的:
if (sections = [arr objectAtIndex:4])
{
/*.....*/
}
Run Code Online (Sandbox Code Playgroud)
要么
sections = [arr objectAtIndex:4]
if (sections == nil)
{
/*.....*/
}
Run Code Online (Sandbox Code Playgroud)
但两者都抛出一个"出界"错误,不允许我继续
(不要用try catch回复因为那不是我的解决方案)
提前致谢
在执行以下代码时,我使用Android的调试器有一种奇怪的行为.变量值在窗口小部件初始化后立即消失.我把它移到手表但它说"Cannot find local variable value".无论我在何处放置变量,在for循环之前或内部,无论如何都表现相同.我也打印了变量,你可以在代码中看到并且它说"value is null"但是当我检查它时if (value == null)它不会停止并最终在尝试将其转换为整数时抛出错误.
代码:
for (int i=0; i < (view != null ? ((ViewGroup)view).getChildCount() : 0); i++)
{
// Get name of the widget for example field__id,
// Convert to field name replacing field__id for id
// or for example field_name to name
// Check if the field exists in the column name, if so, add the ContentValue
View widget = ((ViewGroup)view).getChildAt(i);
String widgetName = …Run Code Online (Sandbox Code Playgroud) 我试图使用NSNotificationCenter从AppDelegate调用uiview中的方法无济于事.
AppDelegate.m
[[NSNotificationCenter defaultCenter] postNotificationName:@"ProcessDidComplete" object:items];
Run Code Online (Sandbox Code Playgroud)
然后通过MainStoryboard,加载主视图,哪个控制器类是MainViewController
在MainViewController.h中我有viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ProcessDidComplete:) name:@"ProcessDidComplete" object:nil];
Run Code Online (Sandbox Code Playgroud)
然后是方法
- (void) ProcessDidComplete:(NSNotification *)pNotification
Run Code Online (Sandbox Code Playgroud)
但它永远不会被召唤.
谢谢你的帮助!
我必须ntp从源代码构建软件包并在一些主机上安装所有软件包.安装后,ntpdate 1.us.pool.ntp.org适用于同步.但是,当我尝试这样做时,ntpdate <ip_add_of_another_host>它向我显示以下错误
21 Jul 18:57:53 ntpdate [18287]:没有适合同步的服务器
更奇怪的是,有时ntpdate <ip_addr_of_another_host>在我尝试之后会有效ntpdate 1.us.pool.ntp.org
我的ntp服务器的配置文件:
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# Specify one or more NTP servers.
# Use servers from …Run Code Online (Sandbox Code Playgroud) 在Android Studio中切换到设计视图时出现以下错误,活动中没有任何变化,以前它曾经工作过:
java.lang.AssertionError: Already disposed
at com.intellij.openapi.components.impl.ComponentManagerImpl.getPicoContainer(ComponentManagerImpl.java:263)
at com.intellij.openapi.components.impl.ComponentManagerImpl.getPicoContainer(ComponentManagerImpl.java:55)
at com.intellij.openapi.components.ServiceManager.getService(ServiceManager.java:40)
at com.intellij.openapi.roots.impl.DirectoryIndex.getInstance(DirectoryIndex.java:31)
at org.jetbrains.android.dom.AndroidXmlExtension.isAvailable(AndroidXmlExtension.java:52)
at com.intellij.xml.XmlExtension.getExtension(XmlExtension.java:48)
at com.intellij.xml.XmlExtension.getExtensionByElement(XmlExtension.java:59)
at com.intellij.psi.impl.source.xml.XmlTagImpl.computeNamespaceMap(XmlTagImpl.java:893)
at com.intellij.psi.impl.source.xml.XmlTagImpl.initNamespaceMaps(XmlTagImpl.java:857)
at com.intellij.psi.impl.source.xml.XmlTagImpl.getAttributeValue(XmlTagImpl.java:631)
at com.android.tools.idea.rendering.PsiResourceItem$1.getDefaultIndex(PsiResourceItem.java:160)
at com.android.ide.common.rendering.api.ArrayResourceValue.getValue(ArrayResourceValue.java:95)
at com.android.ide.common.resources.ResourceResolver.resolveResValue(ResourceResolver.java:272)
at com.android.ide.common.resources.ResourceResolver.resolveResValue(ResourceResolver.java:263)
at com.android.ide.common.resources.ResourceResolver.resolveValue(ResourceResolver.java:258)
at com.android.layoutlib.bridge.android.BridgeContext.obtainStyledAttributes(BridgeContext.java:705)
at android.widget.AbsSpinner.<init>(AbsSpinner.java:71)
at android.widget.Spinner.<init>(Spinner.java:165)
at android.widget.Spinner.<init>(Spinner.java:144)
at android.widget.Spinner.<init>(Spinner.java:128)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.BridgeInflater.onCreateView(BridgeInflater.java:86)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:131)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:758)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:758)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) …Run Code Online (Sandbox Code Playgroud) 我正在尝试为iOS 5构建一个简单的火炬应用程序,如http://developer.apple.com/library/mac/releasenotes/AudioVideo/RN-AVFoundation/_index.html#//apple_ref/doc/uid/TP40010717所述-CH1-DontLinkElementID_17但我得到"Apple Match-O链接器错误:
Undefined symbols for architecture armv7:
"_AVMediaTypeVideo", referenced from:
-[FirstViewController viewDidLoad] in FirstViewController.o
"_OBJC_CLASS_$_AVCaptureDevice", referenced from:
objc-class-ref in FirstViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
任何帮助赞赏
有人吗?
另外:它只在运行项目时发生,如果我只是清理和构建没有错误,并且代码完成检测到库.
谢谢
使用此功能时出现奇怪的错误.在新设备和模拟器上运行良好,但在旧设备上测试应用程序时崩溃..任何线索发生了什么?
public boolean bind(ContentValues values ) throws DatabaseException {
if (values == null) throw new DatabaseException("Values is null");
ArrayList<String> columnNames = this.getColumnNamesArray(AppController.getDBO().getDatabase());
String currentKey = null;
try {
for (String key : values.keySet()) {
currentKey = key;
if (columnNames.contains(key)) {
if (values.get(key ) == null ) {
this._properties.putNull(key);
} else if (values.get(key) instanceof String) {
this._properties.put(key, values.getAsString(key));
} else if (values.get(key) instanceof Integer) {
this._properties.put(key, values.getAsInteger(key));
} else if (values.get(key) instanceof Boolean) {
this._properties.put(key, values.getAsBoolean(key));
} else if (values.get(key) instanceof …Run Code Online (Sandbox Code Playgroud) 我想存储一个键,值对,它允许我通过其位置(排序必须持久)或其键名来获取值.我正在考虑使用HashMap,但我不想遍历所有值以通过索引获取值.
我需要这样的东西:
MyCollection<String, Object> objects = new MyCollection<String, Object>();
objects.put ("id", Object1);
objects.put ("name", Object2);
// And now access the values by index:
Object obj1 = objects.get(1);
// or by key name:
Object obj2 = objects.getByKeyName("name");
Run Code Online (Sandbox Code Playgroud)
什么是最好的集合(它必须是android <11兼容>
我正在使用汇编语言和gdb尝试修改内存地址:
+67 00058093 0f84e8000000 je 0x00058181
id喜欢改变读取84到85的第二个字节,以便指令成为jne.然后我打破代码后在gdb中执行以下操作:
set {char}0x00058094=85
Run Code Online (Sandbox Code Playgroud)
但我得到以下"andnps%xmm0,%xmm5"而不是jne:
(gdb)disas
0x00058093 <-[SWBConditionalImplementations checkRegistration:preferences:callbacks:]+67>: andnps %xmm0,%xmm5
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
在使用api 10在仿真器Nexus S Platform 2.3.3上执行android app时出现以下错误.它适用于带有api 18的Nexus 4 Android 4.3.AppDatabase扩展了SQLiteOpenHelper.
码:
public class AppController extends Application {
[...]
private static AppDatabase mDbo;
[...]
try {
// Here comes the crash, it crashes immediately, i cannot step into
mDbo = new AppDatabase( AppDatabase.NAME,null, new AppSQLiteCursor(),AppDatabase.VERSION) ;
}
}
Run Code Online (Sandbox Code Playgroud)
错误堆栈跟踪:
12-14 23:04:01.996 1372-1372/com.example.myapp E/APP_ERROR? VerifyError raised!
java.lang.VerifyError: com.example.myapp.database.AppDatabase
at com.example.myapp.AppController.onCreate(AppController.java:85)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3272)
at android.app.ActivityThread.access$2200(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at …Run Code Online (Sandbox Code Playgroud)