Classcastexception: Android.widget.linearlayout$layoutparams
So i get this error when executing an adapter in FinderActivity.class. public class FinderActivity extends ListActivity { private List itemsearchoptions = Arrays
Solution 1:
Use android.widget.AbsListView.LayoutParams
instead of the android.widget.LinearLayout.LayoutParams
in your imports.
A ClassCastException stacktrace is pretty descriptive...
Solution 2:
For the rest of you which have the same problem. Please at first, fix your getView method.
Try to make it like this.
public View getView(int i, View view, ViewGroup viewGroup) {
LayoutInflaterlayoutInflater= (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View root;
if(view == null){
root = layoutInflater.inflate(R.layout.yourLayout, null);
} else {
root = view;
}
return root;
}
This may solve the android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
error.
Trust me, I just facing this exact problem, but I manage to solve it this way.
Post a Comment for "Classcastexception: Android.widget.linearlayout$layoutparams"