我从数据库中提取数据,返回类实例中的值。在我的Activity的onCreate方法中,我正在设置内容视图,然后运行以下代码:
val thisObject:ClassCardJ = myDBAdapter.getAddressBookEntry(cardNum)
//val textFullName:String = (thisObject.getfName().toString() + " " + thisObject.getlName().toString())
val textFirstName:String = thisObject.getfName().toString()
val textLastName:String = thisObject.getlName().toString()
firstLine.setText(textFirstName)
Toast.makeText(AddressBookEntryActivity.this, thisObject.getlName().toString(), Toast.LENGTH_SHORT).show();
将firstLine文本设置为textFirstName值,并显示一个toast,其中包含我在textLastName中使用的值。
但是,当我尝试将firstLine的setText更改为textFullName时(取消注释后),我的程序强制关闭。我做了一些有趣的错误吗?
作为请求,我的logcat堆栈跟踪(我试图包含所有相关内容并省略所有不相关的内容):
I/ActivityManager( 67): Process com.android.email (pid 330) has died.
I/ActivityManager( 67): Starting: Intent { cmp=me.snapcard/.AddressBookActivity } from pid 393
I/ActivityManager( 67): Displayed me.snapcard/.AddressBookActivity: +589ms
I/ActivityManager( 67): Starting: Intent { cmp=me.snapcard/.AddressBookEntryActivity (has extras) } from pid 393
E/dalvikvm( 393): Could not find class 'scala.collection.mutable.StringBuilder', referenced from method me.snapcard.AddressBookEntryActivity.onCreate
W/dalvikvm( 393): VFY: unable to resolve new-instance 1148 (Lscala/collection/mutable/StringBuilder;) in Lme/snapcard/AddressBookEntryActivity;
D/dalvikvm( 393): VFY: replacing opcode 0x22 at 0x0050
D/dalvikvm( 393): VFY: dead code 0x0052-0091 in Lme/snapcard/AddressBookEntryActivity;.onCreate (Landroid/os/Bundle;)V
D/AndroidRuntime( 393): Shutting down VM
W/dalvikvm( 393): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime( 393): FATAL EXCEPTION: main
E/AndroidRuntime( 393): java.lang.NoClassDefFoundError: scala.collection.mutable.StringBuilder
E/AndroidRuntime( 393): at me.snapcard.AddressBookEntryActivity.onCreate(AddressBookEntryActivity.scala:40)
E/AndroidRuntime( 393): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 393): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
E/AndroidRuntime( 393): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime( 393): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 393): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 393): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 393): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 393): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 393): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 393): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 393): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 393): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 393): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 67): Force finishing activity me.snapcard/.AddressBookEntryActivity
W/ActivityManager( 67): Force finishing activity me.snapcard/.AddressBookActivity
W/ActivityManager( 67): Activity pause timeout for HistoryRecord{4082ce18 me.snapcard/.AddressBookEntryActivity}
I/dalvikvm( 67): Jit: resizing JitTable from 1024 to 2048
W/ActivityManager( 67): Launch timeout has expired, giving up wake lock!
答案 0 :(得分:1)
就像你说的那样,你使用了StringBuilder。我怀疑你的scala.collection.mutable对象具有不允许其项目顺利连接的编码。我强烈建议你在Scala StringBuilder中包装连接字符串(包括textFirstName和textLastName,如果你将单独使用它们)。如果您想使用java.lang.StringBuilder,那么您可以通过简单地将Scala StringBuilder与java.lang.Stringbuilder包装在一起来转换Scala StringBuilder,详细信息为here。希望有所帮助!