请问这是我下面的代码,我正在粘贴下面的错误消息:我试图在微调器上使用setOnItemClickListener ,是允许的吗?

public void onItemClick(AdapterView<?> arg0, View v, int index, long arg3) {
    if (quantity[index]=="Meter" ){
        Toast.makeText(v.getContext(), "convert from meter",Toast.LENGTH_SHORT).show();


convertto.setOnItemClickListener(new OnItemClickListener()
    public void onItemClick(AdapterView<?> arg, View v1, int index1, long arg4)
        if ((quantity[index1]=="Meter") && (s1.equalsIgnoreCase("Meter")))
            Toast.makeText(v1.getContext(), " to meter",Toast.LENGTH_SHORT).show();
            lresult.setText("" + var2);




07-04 09:48:39.912: E/AndroidRuntime(694): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.a2zunitconverter.miniproject/com.a2zunitconverter.miniproject.lenght}: java.lang.RuntimeException: setOnItemClickListener cannot be used with a spinner.
07-04 09:48:39.912: E/AndroidRuntime(694):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-04 09:48:39.912: E/AndroidRuntime(694):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-04 09:48:39.912: E/AndroidRuntime(694):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-04 09:48:39.912: E/AndroidRuntime(694):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-04 09:48:39.912: E/AndroidRuntime(694):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-04 09:48:39.912: E/AndroidRuntime(694):  at android.os.Looper.loop(Looper.java:123)
07-04 09:48:39.912: E/AndroidRuntime(694):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-04 09:48:39.912: E/AndroidRuntime(694):  at java.lang.reflect.Method.invokeNative(Native Method)
07-04 09:48:39.912: E/AndroidRuntime(694):  at java.lang.reflect.Method.invoke(Method.java:507)
07-04 09:48:39.912: E/AndroidRuntime(694):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-04 09:48:39.912: E/AndroidRuntime(694):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-04 09:48:39.912: E/AndroidRuntime(694):  at dalvik.system.NativeStart.main(Native Method)
07-04 09:48:39.912: E/AndroidRuntime(694): Caused by: java.lang.RuntimeException: setOnItemClickListener cannot be used with a spinner.
07-04 09:48:39.912: E/AndroidRuntime(694):  at android.widget.Spinner.setOnItemClickListener(Spinner.java:102)
07-04 09:48:39.912: E/AndroidRuntime(694):  at com.a2zunitconverter.miniproject.lenght.onCreate(lenght.java:31)
07-04 09:48:39.912: E/AndroidRuntime(694):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-04 09:48:39.912: E/AndroidRuntime(694):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-04 09:48:39.912: E/AndroidRuntime(694):  ... 11 more

Kindly This is my code below, and I am pasting the error messages underneath: I am trying to use setOnItemClickListener on the spinner, is it permissible?and here are the errors


首先,我有一个装有8gb ram的盒子,所以我怀疑总内存是问题所在。 此应用程序在6gb或更少的计算机上运行良好。

我正在尝试在Eclipse的“运行配置”中的“ VM参数”下使用-Xmx3G保留3GB的空间。

每当我尝试保留超过1500mb的内存时,都会出现以下错误:“ VM初始化期间发生错误; -Xmx3G无法为对象堆保留足够的空间”


First of all, I have a box with 8gb of ram, so I doubt total memory is the issue.This application is running fine on machines with 6gb or less.I am trying to reserve 3GB of space using -Xmx3G under “VM Arguments” in Run Configurations in Eclipse.Every time I try to reserve more than 1500mb, I get this error: “Error occurred during initialization of VM;Could not reserve enough space for object heap” using -Xmx3GWhat is going on here?



执行命令行时发生异常。 无法运行程序“ C:\\ Program Files(x86)\\ Java \\ jre6 \\ bin \\ javaw.exe”(在目录“ C:\\ Users \\ motiver \\ helios_workspace \\ TimeTracker”中):CreateProcess错误= 206,文件名或扩展名是太长

我进行了一些研究,但是在使用Google App Engine时,大多数问题与DataNucleus有关。 但是我没有使用与Google App Engine远程相关的任何东西。 我正在JBOSS 6上使用Servlet 3.0做一个小项目。我正在使用Hibernate 4.1.2 for ORM和RESTEasy公开Web服务。 我创建了一个具有main()方法的util文件,该方法基本上删除并重新创建了架构。 当我需要一个干净的数据库进行测试时,我运行main()方法。 它在Tomcat 7上运行良好,但是在我移至JBoss 6时停止了工作。


I have this error in eclipse helios:Exception occurred executing command line.Cannot run program “C:\\Program Files (x86)\\Java\\jre6\\bin\\javaw.exe” (in directory “C:\\Users\\motiver\\helios_workspace\\TimeTracker”): CreateProcess error=206, The filename or extension is too longI researched a bit but most of the issues were related to DataNucleus when working on Google App Engine.But I am not using anything remotely related to Google App Engine.I am doing a small project with Servlet 3.0 on JBOSS 6. I am using Hibernate 4.1.2 for ORM and RESTEasy to expose a web service.I created a util file that has a main() method that basically drops and re-creates the schema.I run the main() methos when I need a clean database for testing purposes.It worked fine on Tomcat 7 but it stopped working when I moved to JBoss 6.Any hint or solution would be greatly appreciated.



  • A与B具有多对多关系。(B具有inverse="true" )
  • B与C具有多对一关系。(我已将cascade设置为"save-update" )
  • C是一种类型/类别表。



当我调用session.saveOrUpdate(myAObject) ,出现一个休眠错误,提示: "a different object with the same identifier value was already associated with the session: C" 我知道休眠无法在同一会话中两次插入/更新/删除相同的对象,但是有什么办法解决吗? 这似乎不是一种罕见的情况。

在研究此问题的过程中,我曾见过有人建议使用session.merge() ,但是当我这样做时,所有“冲突”对象都将作为空白对象插入数据库,并且所有值均设置为null。 显然,这不是我们想要的。


I essentially have some objects in this configuration (the real data model is a bit more complex):A has a many-to-many relationship with B. (B has inverse="true" )B has a many-to-one relationship with C. (I have cascade set to "save-update" )C is a kind of type/category table.Also, I should probably mention that the primary keys are generated by the database on save.With my data, I sometimes run into problems where A has a set of different B objects, and these B objects refer to the same C object.When I call session.saveOrUpdate(myAObject) , I get a hibernate error saying: "a different object with the same identifier value was already associated with the session: C" .I know that hibernate can’t insert/update/delete the same object twice in the same session, but is there some way around this?This doesn’t seem like it would be that uncommon of a situation.During my research of this problem, I have seen folks suggest the use of session.merge() , but when I do that, any “conflicting” objects get inserted into the database as blank objects with all values set to null.Clearly that isn’t what we want.[Edit] Another thing I forgot to mention is that (for architectural reasons beyond my control), each read or write needs to be done in a separate session.


我正在尝试运行以下基本JPA / EJB代码:

public static void main(String[] args){
         UserBean user = new UserBean();


javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.JPA.Database



这是由创建对象的方式引起的,即,如果您显式设置ID属性。 删除ID分配即可解决此问题。


I am trying to run this basic JPA/EJB code:I get this error:Any ideas?I search on the internet and the reason I found was:This was caused by how you created the objects, ie If you set the ID property explicitly.Removing ID assignment fixed it.But I didn’t get it, what will I have to modify to get the code working?