Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid getview() returns nothing
    text
    copied!<p>im calling my layout and setting items for it but the getview() returns nothing .</p> <p>My main class :</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.MymainView); grid = (GridView) findViewById(R.id.grid); if (getScreenOrientation() == 1) grid.setNumColumns(3); else grid.setNumColumns(4); items = new ArrayList&lt;LauncherGridItem&gt;(); Intent intent = new Intent(this, Activity2.class); intent.putExtra("Param1", "Child Activity"); items.add(new LauncherGridItem("ic_launcher", "Item 1", intent)); adapter = new LauncherGridAdapter(this, items, grid, dragLayer, deleteZone); adapter.setPersistenceToken("MyLauncherGrid"); adapter.setDragListener(this); adapter.setEditable(true); grid.setAdapter(adapter); </code></pre> <p>And My LauncherGridAdapter , getview() section in file :</p> <pre><code> public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = inflater .inflate(R.layout.grid_view_item_layout, null); holder = new ViewHolder(); holder.image = (ImageView) convertView .findViewById(R.id.selection_item_image); holder.text = (TextView) convertView .findViewById(R.id.selection_item_text); convertView.setTag(holder); //holder.image.setPadding(8, 8, 8, 8); } else { holder = (ViewHolder) convertView.getTag(); } DraggableRelativeLayout layout = (DraggableRelativeLayout) convertView; convertView.setOnLongClickListener(this); convertView.setOnClickListener(this); LauncherGridItem item = getItems().get(position); layout.setItem(item); layout.setDragListener(this); // holder.image.setOnLongClickListener(this); Drawable d = holder.image.getDrawable(); // if (d != null) { d.setCallback(null); // } holder.image.setImageDrawable(null); if (!item.getUrl().startsWith("http")) { try { holder.image.setImageDrawable(context.getResources() .getDrawable( context.getResources().getIdentifier( context.getApplicationContext() .getPackageName() + ":drawable/" + item.getUrl(), null, null))); } catch (NotFoundException e) { holder.image.setImageResource(android.R.drawable.ic_menu_view); } } else { // Image cached = images.get(position); if(item.getImage() == null) { holder.image.setImageResource(R.drawable.avatar); } else { holder.image.setScaleType(ScaleType.CENTER_INSIDE); holder.image.setImageBitmap(item.getImage()); } } } holder.text.setText(item.getCaption()); layout.setImage(holder.image); layout.setText(holder.text); layout.setItem(item); layout.canDelete(item.canDelete()); return convertView; </code></pre> <p>}</p> <p>i even checked the if statement and program items are valid and not null. ive also added these but still nothing in gridview :</p> <pre><code>@Override public int getCount() { return getItems().size(); } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { </code></pre> <p>i guess the problem is "grid_view_item_layout" not showing at all </p> <p>this is the "main" layout :</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#CCCCCC"&gt; &lt;com.myapp.ui.drag.DragLayer xmlns:android="http://schemas.android.com/apk/res/android" xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher" android:id="@+id/drag_layer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@+id/handle"&gt; &lt;GridView android:id="@+id/grid" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginBottom="65dip" android:background="@color/BlanchedAlmond" android:numColumns="3" android:scrollbars="vertical" /&gt; &lt;com.myapp.ui.drag.DeleteZone android:id="@+id/delete_zone_view" android:layout_width="fill_parent" android:layout_height="60dp" android:layout_alignParentBottom="true" android:layout_centerInParent="true" android:background="@drawable/delete_zone_bg" android:visibility="gone"&gt; &lt;ImageView android:layout_width="60dp" android:layout_height="60dp" android:layout_centerInParent="true" android:src="@drawable/trashcan" /&gt; &lt;/com.myapp.ui.drag.DeleteZone&gt; &lt;/com.myapp.ui.drag.DragLayer&gt; &lt;/LinearLayout&gt; </code></pre> <p>and this is grid_view_item_layout layout :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;com.myapp.ui.drag.DraggableRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/CadetBlue" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/selection_item_image" android:scaleType="centerInside" android:src="@drawable/avatar" android:layout_width="wrap_content" android:layout_height="60dip" android:layout_centerHorizontal="true" /&gt; &lt;TextView android:layout_width="wrap_content" android:id="@+id/selection_item_text" android:maxLines="1" android:lines="1" android:scrollHorizontally="true" android:ellipsize="end" android:layout_height="wrap_content" android:textColor="@android:color/black" android:text="(Selection Text)" android:layout_below="@+id/selection_item_image" android:layout_centerHorizontal="true" &gt;&lt;/TextView&gt; &lt;/com.myapp.ui.drag.DraggableRelativeLayout&gt; </code></pre> <p>im using plusgridlayout for moving items between gridview . the function works on source project but when i try to release it under mine no error happen plus no gridview at all.</p> <p>also if i change the last line of getview() from return convertView; to return layout; still nothing apears.</p>
 

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