classcastexception

ClassCastException LinearLayout LayoutParams

最后都变了- 提交于 2019-11-29 18:27:23
问题 I got an Actionbar and some Fragments. The Problem is my Homescreen. There is an overview Fragment on the left side and a detail Fragment on the right side. My TabListener is Dynamic so i want to set the weight of my Layout programatically. Whenever i try to get the Layoutparams of my LinearLayout i get a ClassCastException: 12-22 16:00:37.620: W/System.err(7235): java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams

Why wrapping a generic method call with Option defers ClassCastException?

最后都变了- 提交于 2019-11-29 09:14:19
Lets say I have an array like this*: val foo: Any = 1 : Int Option(foo.asInstanceOf[String]) which fails for obvious reason: // java.lang.ClassCastException: java.lang.Integer cannot be cast to // java.lang.String // ... 48 elided Next lets consider a following class: case class DummyRow() { val foo: Any = 1 : Int def getAs[T] = foo.asInstanceOf[T] def getAsOption[T] = Option(foo.asInstanceOf[T]) } As far as I can tell getAs should behave the same way as the previous apply followed by asInstanceOf . Surprisingly it is not the case. When called alone it throws an exception: DummyRow().getAs

java.lang.ClassCastException: org.json.simple.JSONArray cannot be cast to org.json.JSONArray

跟風遠走 提交于 2019-11-29 07:34:23
I need to read a JsonArray data from a file (on an SD card) and store it into a SQLite database. but I am getting a java.lang.ClassCastException: org.json.simple.JSONArray cannot be cast to org.json.JSONArray exception while parsing data to JsonArray . Data in the file is very huge, the whole data can not be stored in a single String or String Buffer or String Builder. Here is my code. FileReader fileReader = new FileReader(file_path); Object obj = jsonParser.parse(fileReader); JSONArray jsonArray = (JSONArray) obj; // Exception. Please help.. Check your import statements at the top of your

List to TreeSet conversion produces: “java.lang.ClassCastException: MyClass cannot be cast to java.lang.Comparable”

◇◆丶佛笑我妖孽 提交于 2019-11-29 06:19:40
List<MyClass> myclassList = (List<MyClass>) rs.get(); TreeSet<MyClass> myclassSet = new TreeSet<MyClass>(myclassList); I don't understand why this code generates this: java.lang.ClassCastException: MyClass cannot be cast to java.lang.Comparable MyClass does not implement Comparable. I just want to use a Set to filter the unique elements of the List since my List contains unncessary duplicates. polygenelubricants Does MyClass implements Comparable<MyClass> or anything like that? If not, then that's why. For TreeSet , you either have to make the elements Comparable , or provide a Comparator .

Get All Installed Application icons in Android : java.lang.ClassCastException

狂风中的少年 提交于 2019-11-29 03:50:52
There is a java.lang.ClassCastException when I am trying to get a installed applications icon. Here is my code. public Bitmap getAppIcon(String path) { PackageInfo pi = pm.getPackageArchiveInfo(path, 0); pi.applicationInfo.sourceDir = path; pi.applicationInfo.publicSourceDir = path; Drawable icon = pi.applicationInfo.loadIcon(pm); Bitmap APKicon = ((BitmapDrawable) icon).getBitmap(); return APKicon; } where, pm is PackageManager pm = getPackageManager(); and the error shown in the LogCat is Caused by: java.lang.ClassCastException: android.graphics.drawable.NinePatchDrawable cannot be cast to

ClassCastException, casting Integer to Double

断了今生、忘了曾经 提交于 2019-11-28 19:37:33
问题 ArrayList marks = new ArrayList(); Double sum = 0.0; sum = ((Double)marks.get(i)); Everytime I try to run my program, I get a ClassCastException that states: java.lang.Integer cannot be cast to java.lang.Double 回答1: We can cast an int to a double but we can't do the same with the wrapper classes Integer and Double : int a = 1; Integer b = 1; // inboxing, requires Java 1.5+ double c = (double) a; // OK Double d = (Double) b; // No way. This shows the compile time error that corresponds to your

CXF - ClassCastException (SEIStub/ClientProxy)

流过昼夜 提交于 2019-11-28 12:18:49
I'm trying to build a client jar file to access a webservice. I'm including the jar in a servlet/war that makes the client webservice calls. I'm getting the following error: INFO: 2011 Apr 14 14:57:32,780 MDT [http-thread-pool-8181(4)] ERROR my.package.ClientServlet - Caught exception java.lang.ClassCastException: com.sun.xml.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy at org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:93) at my.package.Client.<init>(Client.java:54) at my.package.ClientServlet.testService(TestServlet.java:118) I came across this

ClassCastException when Appending Object OutputStream

本小妞迷上赌 提交于 2019-11-28 10:21:53
I have been trying to do a little project that needs an appendable ObjectOutputStream. I have gone through a couple of solutions and i found this It seemed to solve my problem at first. But on further development of my project i started getting unexpected exceptions. The following are my classes. public class PPAccount implements Serializable { private Profile profile; private String email; private float accountBal; private boolean isActivated; private String activationCode; private ArrayList<Transaction> transactions; //a few functions } public class PPRestrictedAccount extends PPAccount {

ClassCastException

岁酱吖の 提交于 2019-11-28 08:18:34
问题 i have two classes in java as: class A { int a=10; public void sayhello() { System.out.println("class A"); } } class B extends A { int a=20; public void sayhello() { System.out.println("class B"); } } public class HelloWorld { public static void main(String[] args) throws IOException { B b = (B) new A(); System.out.println(b.a); } } at compile time it does not give error, but at runtime it displays an error : Exception in thread "main" java.lang.ClassCastException: A cannot be cast to B 回答1:

Primefaces datatable date range filter with filterFunction

寵の児 提交于 2019-11-28 07:49:44
I use filterFunction method of datatable on primefaces 5.0. I want to filter birthday by date range on column header. On browser console I receive this error: <?xml version="1.0" encoding="utf-8"?><partial-response><error><error-name>java.lang.ClassCastException</error-name><error-message><![CDATA[javax.faces.component.UIPanel cannot be cast to javax.faces.component.ValueHolder]]></error-message></error></partial-response> Datatable : <p:dataTable var="person" value="#{testDateRange.persons}" id="personTable" paginator="true" styleClass="customTableStyle" editable="true" rows="10"