2012-04-19 2 views
0

Я создал этот XML-файл, который отображает список разных элементов, и я решил добавить объявления в этот список, но проблема в том, что объявление охватывает первый элемент в списке и перескакивает второй пункт напрямую. Скажите, как мне переопределить эту проблему? Еще одна вещь, которую я ищу, - это изменить гравитацию этого списка, который будет отображаться справа, а не слева. Вот изображение, которое иллюстрирует мои проблемы: enter image description hereразмещение объявлений в списках

XML-файл:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:id="@+id/list_container" 
    android:measureAllChildren="true" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent"> 

<ListView android:id="@android:id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:drawSelectorOnTop="false" 
     android:focusableInTouchMode="true" 
    /> 

<ScrollView android:id="@+id/edit_layout" 
    android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
    android:visibility="gone" 
    >  
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="5sp" 
     android:paddingLeft="10sp" 
     android:gravity="right" 
     android:paddingRight="15sp" 
     > 
     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/list_descption_label" 
      android:gravity="right" 
     /> 
     <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:clickable="true" 
      android:singleLine="true" 
      android:hint="@string/list_descption_label" 
      android:id="@+id/list_description" 
      android:inputType="textUri" 
      /> 
     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/list_username_label" 
      android:gravity="right" 
     /> 
     <AutoCompleteTextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:singleLine="true" 
      android:hint="@string/list_username_label" 
      android:id="@+id/list_username" 
      android:imeOptions="actionNext" 
      /> 
     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/list_password_label" 
      android:gravity="right" 
     /> 
     <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:singleLine="true" 
      android:hint="@string/list_password_label" 
      android:id="@+id/list_password" 
      android:inputType="textVisiblePassword" 
      /> 
     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/list_email_label" 
      android:gravity="left" 
     /> 
     <AutoCompleteTextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:singleLine="true" 
      android:hint="@string/list_email_label" 
      android:id="@+id/list_email" 
      android:inputType="textEmailAddress" 
      android:imeOptions="actionNext" 
      /> 
     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/list_notes_label" 
      android:gravity="right" 
     /> 
     <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:gravity="top|left" 
      android:minLines="5" 
      android:hint="@string/list_notes_label" 
      android:id="@+id/list_notes" 
      android:inputType="textMultiLine" 
      /> 

    </LinearLayout> 

</ScrollView> 
<com.google.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    ads:adSize="BANNER" 
    ads:adUnitId="xxxxxxxxx" 
    ads:loadAdOnCreate="true" > 
</com.google.ads.AdView> 

ответ

0

Установить заголовок ListView. Создание макета XML с вашим

<com.google.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    ads:adSize="BANNER" 
    ads:adUnitId="xxxxxxxxx" 
    ads:loadAdOnCreate="true" > 
</com.google.ads.AdView> 

Надуйте его и добавить его в ListView.

inflater = (LayoutInflater) context.getSystemService(
             Context.LAYOUT_INFLATER_SERVICE); 
View adView = inflater.inflate(R.layout.myAdView, null, false); 
yourListView.addHeaderView(adView); 

Для вашего второго вопроса, скопируйте android.R .... макет вы используете из SDK и изменить гравитацию или настроить adaper.

Смежные вопросы