0
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="170dp"
        android:background="#fff" >

        <AutoCompleteTextView
            android:id="@+id/location_view"
            android:layout_width="150dp"
            android:layout_height="35dp"
            android:layout_alignLeft="@+id/category_view"
            android:layout_below="@+id/category_view"
            android:layout_marginTop="16dp"
            android:ems="10"
            android:hint="@string/location"
            android:textSize="@dimen/autocomplettextview"
            />

        <AutoCompleteTextView
            android:id="@+id/category_view"
            android:layout_width="150dp"
            android:layout_height="35dp"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="21dp"
            android:ems="10"
            android:hint="@string/category"
            android:textSize="@dimen/autocomplettextview"
            android:textColor="#000"
            >

            <requestFocus />
        </AutoCompleteTextView>

        <Button
            android:id="@+id/getquote_button"
            android:layout_width="150dp"
            android:layout_height="40dp"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:background="@drawable/getquote"
            android:paddingLeft="10dp"
            android:paddingRight="10dp" />

    </RelativeLayout>

<include layout="@layout/First_layout" 

    android:visibility="visible">
   </include>
<include layout="@layout/second_layout"
    android:visibility="invisible"

    />   
   </LinearLayout>

I wanted to make the second view to visible and visibility of first view to invisible on the item selected of the autocomplete View As The User select the Item From the AutoComplete View List The Second Layout Gets Visible And The First Layout will be Invisible

Giant
  • 1,619
  • 7
  • 33
  • 67

3 Answers3

0

assign your include tag an "ID" and use findViewById to get the reference and set Visibility to View.Visible.

<include layout="@layout/second_layout"
    android:id="@+id/second_view"
    android:visibility="invisible"
    /> 

in java:

   View view = findViewById(R.id.second_view);
   view.setVisibility(View.Visible); 
vipul mittal
  • 17,343
  • 3
  • 41
  • 44
0

You can try OnItemClickListener for that AutoCompleteTextview.:

textView.setOnItemClickListener(new OnItemClickListener() { 

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
            long arg3) {
        view2.setVisibility(View.Visible);
        view1.setVisibility(View.GONE);
    }
});

Hope it helps.

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
0

Lets say you have a button

Button one = (Button)findViewByID(R.id.ButtonID1);
Button two = (Button)findViewByID(R.id.ButtonID2);

on selection of your desired value in autocomplete - use this link

and put

one.setVisibiity(View.GONE);
two.setVisibility(View.VISIBLE);

in its onItemClick

Community
  • 1
  • 1
Darpan
  • 5,623
  • 3
  • 48
  • 80