видоискатель Android не меняет вид: HELP! :) - PullRequest
0 голосов
/ 07 сентября 2010

У меня проблемы с работой видоискателя.Я создал XML-файл макета view_flipper.xml:

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

    <include android:id="@+id/MainView"  layout="@layout/gallery_1" />

    <include android:id="@+id/SearchView"  layout="@layout/search_internal" />

</ViewFlipper>

макет gallery_1 - это просто ListView.макет search_internal имеет текст редактирования, кнопку и просмотр списка.

Я использую:

 ViewFlipper theFlipper=(ViewFlipper) findViewById(R.id.flipper);
    theFlipper.setDisplayedChild( R.id.SearchView );

, чтобы изменить макет, но, очевидно, он работает для кода, но на дисплее,ничего не происходит ... Может кто-нибудь помочь?

Вот код раскладки search_internal:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/SearchBox"
>
<EditText android:text="" 
android:id="@+id/QueryText" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:layout_marginRight="100px"
></EditText>
<Button android:layout_height="wrap_content" 
android:id="@+id/BtnOk" 
android:layout_width="wrap_content" 
android:layout_alignParentRight="true"
android:text="@string/searchBtnTxt"
android:clickable="true"></Button>
</LinearLayout>
<ListView
android:id="@+id/list_view_id"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/SearchBox"
android:background="#FFFFFF"
android:cacheColorHint="#FFFFFF"
android:layout_marginBottom="65dip"
android:gravity="top"
/>
</RelativeLayout>

1 Ответ

2 голосов
/ 07 сентября 2010

Я обнаружил, что неправильно использовал функцию setDisplayedChild. setDisplayedChild, очевидно, является нулевым индексом. К сожалению.

    theFlipper.setDisplayedChild( 0 );
...