Android: ClassCastException when adding a header view to ExpandableListView

Ok, I figured this one out. I got rid of the runtime error by programatically setting the View’s LayoutParams to ListView LayoutParams, like so: headerView.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, ListView.LayoutParams.WRAP_CONTENT)); before adding the view. The reason being is found in the Android docs: http://developer.android.com/reference/android/view/View.html#setLayoutParams(android.view.ViewGroup.LayoutParams) which states that: These supply parameters to the parent of this view specifying how … Read more

ClassCastException: RestTemplate returning List instead of List

With the following method call List<MyModelClass> myModelClass=(List<MyModelClass>) restTemplate.postForObject(url,mvm,List.class); All Jackson knows is that you want a List, but doesn’t have any restriction on the type. By default Jackson deserializes a JSON object into a LinkedHashMap, so that’s why you are getting the ClassCastException. If your returned JSON is an array, one way to get it … Read more

android.app.Application cannot be cast to android.app.Activity

You are passing the Application Context not the Activity Context with getApplicationContext(); Wherever you are passing it pass this or ActivityName.this instead. Since you are trying to cast the Context you pass (Application not Activity as you thought) to an Activity with (Activity) you get this exception because you can’t cast the Application to Activity … Read more

ClassCastException when casting to the same class

I am not quite following your description of the program flow, but usually when you get ClassCastExceptions you cannot explain you have loaded the class with one classloader then try to cast it to the same class loaded by another classloader. This will not work – they are represented by two different Class objects inside … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)