Note that there are some explanatory texts on larger screens.

plurals
  1. POListView have only one item
    primarykey
    data
    text
    <p>I have a ListView that is showing only one item instead of two. thats my MainActivity:</p> <pre><code>public class MainActivity extends Activity { ImageView Add; ImageView Shadow; ProgressBar PB; ListView listView; String[] valuesUp = { "Lorem ipsum dolor sit amet, consectetur adipiscing elit", "Sed non justo eros. Praesent a nisl dui" }; String[] valuesDown = { "Quisque ut ante eu arcu sagittis porta eu a dolor...", "In orci augue facilisis eget fermentum consequat ac..." }; int[] imgValues = {R.drawable.mobileapp_16, R.drawable.mobileapp_19}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ArrayAdapter&lt;String&gt; adapter = new MyAdapter(this, valuesUp, valuesDown, imgValues); listView = (ListView) findViewById(R.id.listView1); listView.setAdapter(adapter); } </code></pre> <p>and thats my Adapter:</p> <pre><code>public class MyAdapter extends ArrayAdapter&lt;String&gt; { private final Context context; private final String[] valuesUp; private final String[] valuesDown; private final int[] ImageValue; private TextView textViewUp; private TextView textViewDown; private ImageView image; public MyAdapter(Context context, String[] valuesUP, String[] valuesDown, int[] imageValue) { super(context, R.layout.rowlayout, valuesUP); this.context = context; this.valuesUp = valuesUP; this.valuesDown = valuesDown; this.ImageValue = imageValue; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView; rowView = inflater.inflate(R.layout.rowlayout, parent, false); textViewUp = (TextView) rowView.findViewById(R.id.row_text_view_up); textViewDown = (TextView) rowView.findViewById(R.id.row_text_view_down); image = (ImageView) rowView.findViewById(R.id.image); textViewUp.setText(valuesUp[position]); textViewDown.setText(valuesDown[position]); image.setImageDrawable(context.getResources().getDrawable(ImageValue[position])); return rowView; }} </code></pre> <p>When I debug I see that the getView is getting called a lot of times (about 12) and all of the time the "position" is 0. Why is That? Thanks!</p> <p>I found my problem now! Its weird. the height of the list is acting weird. when I am doing "wrap_content or match_parent it gives me one item but when for example I a puting 400dp its ok. why is that?! Thats my XML:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/progress" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:background="@drawable/topbar_bg" /&gt; &lt;ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/imageView1" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:src="@drawable/topbar_leftcircle" /&gt; &lt;ImageView android:id="@+id/imageView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/imageView1" android:layout_alignParentTop="true" android:layout_marginLeft="5dp" android:layout_toRightOf="@+id/imageView2" android:src="@drawable/topbar_logo" /&gt; &lt;ImageView android:id="@+id/imageView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/imageView1" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginRight="5dp" android:scaleType="fitStart" android:src="@drawable/topbar_menu" /&gt; &lt;ImageView android:id="@+id/imageView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/imageView1" android:layout_alignParentTop="true" android:layout_marginRight="5dp" android:layout_toLeftOf="@+id/imageView4" android:src="@drawable/topbar_key" /&gt; &lt;ScrollView android:id="@+id/scrollView2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true" android:layout_below="@+id/imageView1" android:layout_centerHorizontal="true" &gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;ImageButton android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/imageView1" android:layout_centerHorizontal="true" android:background="#00000000" android:src="@drawable/mobileapp_14" /&gt; &lt;ImageView android:id="@+id/imageView6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/imageButton1" android:layout_centerHorizontal="true" android:scaleType="fitXY" android:src="@drawable/transparent_bg" /&gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignTop="@+id/imageView6" android:layout_marginBottom="5dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="10dp" android:maxLines="2" android:text="Sed at vestibulum elit. Nunc quam erat, gravida ac consequat" android:textColor="@color/RedText" android:textSize="15dp" /&gt; &lt;TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/imageButton1" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_below="@+id/textView1" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:maxLines="2" android:text="Nullam sed erat erat, ut faucibus nunc. Etiam et mi di ante lacinia suscipit. Mauris gravida turpis eget lectus ullam..." android:textColor="@color/WhiteText" android:textSize="12dp" /&gt; &lt;ImageView android:id="@+id/imageView7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/imageButton1" android:layout_centerHorizontal="true" android:background="#00000000" android:scaleType="centerCrop" android:src="@drawable/mobileapp_15" /&gt; &lt;ListView android:id="@+id/listView1" android:layout_width="match_parent" android:layout_height="600dp" android:layout_below="@id/imageView7" &gt; &lt;/ListView&gt; &lt;/RelativeLayout&gt; &lt;/ScrollView&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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