Note that there are some explanatory texts on larger screens.

plurals
  1. POextended GridViewAdapter
    primarykey
    data
    text
    <p>I have overriden the method getView of my Custom BaseAdapter to fill a Gridview with this:</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { RelativeLayout relativeLayout; if(convertView == null){ relativeLayout = (RelativeLayout)getItem(position); } else{ relativeLayout = (RelativeLayout)convertView; } return relativeLayout; } </code></pre> <p>But all the time, i get this Exception and i dont get it why i get it... getItem(position) should return a Rectangle which is a custom RelativeLayout. Can you please help me?</p> <pre><code>java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams </code></pre> <p>EDIT:</p> <p>i already have a custom RelativeLayout which looks like this:</p> <p>and in my getView i get one of these Rectangles which i have in an arraylist back.. isnt this right?</p> <pre><code>public class Rectangle extends RelativeLayout{ public Rectangle(Context context, int dnd_drag_button_while_dragging, String text) { super(context); this.context = context; LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); this.setLayoutParams(params); ImageView image = new ImageView(context); image.setBackgroundResource(dnd_drag_button_while_dragging); image.setLayoutParams(params); img = dnd_drag_button_while_dragging; LayoutParams tParams = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); tParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); TextView textView = new TextView(context); textView.setText(text); textView.setLayoutParams(tParams); this.addView(image); this.addView(textView); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload