2011-09-15 3 views
0

は、私は、次のXMLレイアウトがありません:AndroidのハニカムのListViewはロードされませんが、例外のいずれか

<LinearLayout 
     android:id="@+id/map_locations_list" 
     android:layout_width="300dp" 
     android:layout_height="fill_parent" 
     android:layout_marginLeft="8dp" 
     android:layout_marginTop="8dp" 
     android:layout_marginBottom="8dp" 
     android:background="@color/black_shadow" 
     android:layout_gravity="left"> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:orientation="vertical"> 
       <TextView 
        android:id="@+id/location_results_info" 
        android:layout_width="fill_parent" 
        android:layout_height="56dp" 
        android:background="@android:color/white" 
        android:text="Stuff goes here" 
        android:padding="10dp" 
       /> 
       <ListView 
        android:id="@+id/locations_view" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1.0" 
       /> 
       <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:text="this is a test" /> 
      </LinearLayout> 
    </LinearLayout> 

<fragment class="fragmentClass" 
    android:id="@+id/fragmentId" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/>  

とリストビューをロードするには、次のJavaコード:

String lv_arr[]={"Android","iPhone","BlackBerry","AndroidPeople"}; 
ListView locationsLV = (ListView)findViewById(R.id.locations_view); 
locationsLV.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr)); 

ListViewには値がロードされませんが、例外をスローしません。私は何が間違っているのか分かりません。私は私のコードの基礎としてこの例を使用:http://www.androidpeople.com/android-listview-example

+0

例外が発生しますか? –

答えて

1

チェックこのXMLと.............そのコンポーネントのoverllappingすることができる他のコンポーネントを追加し、最初の試してみて

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout android:id="@+id/locations_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <ListView android:id="@+id/ListView01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 
    </LinearLayout> 
+0

ありがとう、このアプローチは働いた。 – CACuzcatlan

関連する問題