2016-11-08 3 views
0

Ich versuche, meine Listview über einen Array-Adapter zu binden. Ich habe meine Listenansicht in einem LayoutKann nicht in der Listenansicht

activity_menu.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<TableLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <TableRow> 
     <ImageView android:layout_height="wrap_content" 
      android:layout_width = "wrap_content" 
      android:src="@drawable/saltnpepper" 
      android:layout_weight="1" 
      android:scaleType="centerInside"/> 
    </TableRow> 

    <TableRow android:paddingTop="@android:dimen/app_icon_size"><TextView></TextView></TableRow> 
<TableRow> 
    <ListView android:id="@+id/list1" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_margin="10dp"> 

    </ListView> 
</TableRow> 
</TableLayout> 

Dann habe ich ein anderes Layout mit Textview in der Listenansicht

menulist.xml

zu laden
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<TextView 
    android:id="@+id/nameText" 
    android:text="@string/app_name" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:textSize="16sp" 
    android:textStyle="bold"/> 

In meinem Code ich tue das folgende aber meine Listenansicht geladen nie einmal

ArrayList<String> alTest = new ArrayList<String>(); 
alTest.add("One"); 
alTest.add("Two"); 

ArrayAdapter<String> catAdapter = new ArrayAdapter<String>(this, R.layout.menulist, R.id.nameText, alTest); 
ListView list = (ListView)findViewById(R.id.list1); 
list.setAdapter(catAdapter); 

ich auch einfache Array versucht haben, anstelle von Arraylist Altest aber funktionierte nicht

+0

Sie erweitern. –

Antwort

0

So war das Problem nicht das listview wurde geladen, aber das Imageview, bevor es mehr Bildschirm abgedeckt wurde !! Auch Jetzt habe ich ein anderes Problem (auf einem neuen Thread Posting)

<TableRow android:layout_weight="1" android:gravity="center"> 
     <ImageView android:layout_height="200dp" 
      android:layout_width = "match_parent" 
      android:src="@drawable/saltnpepper"     
      android:scaleType="centerInside" /> 
    </TableRow> 

Das Bild doesnot die gesamte Breite des Bildschirms haben auch in Ihrer `Logs` zeigen, dass etwas

Verwandte Themen