2012-02-29 3 views
1

Как и в случае контактов в разделе контактов андроидов, в котором есть панель поиска сверху, с динамическим видом списка ниже, example here, я пытаюсь использовать счетчик вместо текстового поля ,статический заголовок с проблемами динамического просмотра списка

Моя проблема заключается в том, что в макете Spinner повторяет элемент списка.

У меня есть следующий list.xml файл:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/relativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <Spinner 
     android:id="@+id/spinner1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" /> 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/row" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 

      <ImageView 
       android:id="@+id/icon" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/sc" /> 

      <TextView 
      android:id="@+id/rowData" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 

     </LinearLayout> 
</RelativeLayout> 

и последующей Java:

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    application = ((MyAppApplication) getApplication()); 
    populateOffers(); 
} 

private void populateOffers() 
{ 
    MyAppRequestor MyApp = new MyAppRequestor(); 
    ArrayList<String> list = MyApp.items(application.getMyAppId()); 

    adapter = new ArrayAdapter<String>(this, 
      R.layout.list, R.id.rowData, list); 
    setListAdapter(adapter);   
} 

ответ

1

Поскольку вы используете list.xml в макете это будет повторяться .. Если вы хотите использовать счетчик только один раз, тогда вам нужно поместить основной макет (макет, где вы определили представление списка как компонент.

0

try t его список.xml

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

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <Spinner 
     android:id="@+id/spinner1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" /> 
</LinearLayout> 
    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 
<ImageView 
       android:id="@+id/icon" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/sc" /> 

      <TextView 
      android:id="@+id/rowData" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 

     </LinearLayout> 
Смежные вопросы