I have asked this question before with other adapters like SimpleAdapter but the solution for the simple adapter is not working for ArrayAdapter. In a SimpleAdapter I got the screen width & height then passed that to my RelativeLayout for the data row. The effect was that only one record filling the entire screen was shown at a time. That was fine with static data but now I want to use mutable data.
In short I really don't want to pass the height and width at all. My XML layout is using dip so the screen sizes can change all they want. What I am REALLY after is a way to control the getView call to just one record at a time.
Anyway using the workaround from SimpleAdapter I thought passing the height and width just like before would work but for some reason this time I'm getting an error I can't figure out. Here is the code that sets the width and height:
RelativeLayout.LayoutParams szParms = new RelativeLayout.LayoutParams(mWidth, mHeight);
vw_BigRow.setLayoutParams(szParms);
The height and width are determined elsewhere and are accurate across all devices I've tested with. Not really sure what else to post so just tell me and I add that code / info to the question.
E/AndroidRuntime(404): FATAL EXCEPTION: main
E/AndroidRuntime(404): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
Edit
As has been correctly pointed out my error occurs with a CastClassException however I am still not doing the assignment right as I continue to get the error. I have tried in the activity to set the height / width with the following:
AbsListView.LayoutParams szParms = new AbsListView.LayoutParams(mWidth, mHeight);
lstvw_LiftData.setLayoutParams(szParms);
E/AndroidRuntime(1886): FATAL EXCEPTION: main
E/AndroidRuntime(1886): java.lang.ClassCastException: android.widget.AbsListView$LayoutParams
and
ListView.LayoutParams szParms = new ListView.LayoutParams(mWidth, mHeight);
lstvw_LiftData.setLayoutParams(szParms);
E/AndroidRuntime(1886): FATAL EXCEPTION: main
E/AndroidRuntime(1886): java.lang.ClassCastException: android.widget.AbsListView$LayoutParams
the lstvw_LiftData is a valid ref and not null.
Inside the getView() override of the ArrayAdapter I also try to set the values with the same result
@Override
public View getView(int position, View convertView, ViewGroup parent)
{...}
The only thing I can get to work is this and then a couple, Not All, but a couple of my elements are ignoring their layout positioning and going straight to the bottom.
View vw_BigRow = convertView;
if (vw_BigRow == null)
{
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
vw_BigRow = inflater.inflate(R.layout.liftdatalayout, null);
}
vw_BigRow.setMinimumHeight(mHeight);
vw_BigRow.setMinimumWidth(mWidth);