Hi,

You can show and hide views by using the setVisibility() method.
http://code.google.com/android/reference/android/view/View.html#setVisibility(int)

Some sample code for View's Visibility feature is at:
http://code.google.com/android/samples/ApiDemos/src/com/google/android/samples/view/Visibility1.html

Hope this helps!

-Megha


On Wed, May 21, 2008 at 5:18 AM, rutu <[EMAIL PROTECTED]> wrote:

>
> hi fiends,
> my program already contains an spinner i want that when a item is
> selected it should open another spinner. i tried to do this but i have
> to use  another xml which opens the previous spinner and newer also.
> so for first one i have to right the same code in the another file
> again. can u suggest me ways how to do this without rewriting the code
> for previous spinner again.
>
> HERE IS THE CODE WHICH POPULATES FIRST SPINNER
> public void onCreate(Bundle icicle) {
>        super.onCreate(icicle);
>        setContentView(R.layout.main);
>        s1 = (Spinner) findViewById(R.id.spinner1);
> ArrayAdapter<CharSequence> adapter =
> ArrayAdapter.createFromResource(this, R.array.colors,
>                        android.R.layout.simple_spinner_item);
>
>
> adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
>        s1.setAdapter(adapter);
>  s1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
> {
>
>                        public void onItemSelected(AdapterView parent, View
> v,
>                                        int position, long id) {
>                                // TODO Auto-generated method stub
>
>  if(s1.getSelectedItem().toString().equals("yellow")){
>                                     openNewPage();
>                                }
>
> public void onNothingSelected(AdapterView arg0) {
>                                // TODO Auto-generated method stub
>
>                        }
>
>        });
>
>  private void openNewPage() {
>        Intent i = new Intent(this,SpinnerNavigates.class);
>
>        startSubActivity(i, ACTIVITY_NAVIGATE);
>    }
>
> XML CODE FOR THIS FILE
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>    android:orientation="vertical"
>    android:layout_width="fill_parent"
>    android:layout_height="wrap_content">
>
>   <Spinner android:id="@+id/spinner1"
>        android:layout_width="fill_parent"
>        android:layout_height="wrap_content"
>        android:drawSelectorOnTop="true"
>    />
>
> FOR ANOTHER FILE
>    <Button android:id="@+id/btnChange"
>    android:layout_width="fill_parent"
>    android:layout_height="wrap_content"
>    android:text="Changes"
>    />
>
>
> </LinearLayout>
> IN SpinnerNavigates CLASS I WRITE THE CODE
>        protected void onCreate(Bundle icicle) {
>                // TODO Auto-generated method stub
>                super.onCreate(icicle);
>                setContentView(R.layout.navigate);
>
>
>                s1=(Spinner)findViewById(R.id.spinnerMain);
>                ArrayAdapter<CharSequence> adapter =
> ArrayAdapter.createFromResource(this, R.array.colors,
>                        android.R.layout.simple_spinner_item);
>
>
> adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
>        s1.setAdapter(adapter);
>
>
>        s2=(Spinner)findViewById(R.id.spinnerNavigate);
>                ArrayAdapter<CharSequence> adapter2 =
> ArrayAdapter.createFromResource(this, R.array.planets,
>                        android.R.layout.simple_spinner_item);
>
>
> adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
>        s2.setAdapter(adapter2);
>
>
>        }
> THEN FOR THIS XML CODE IS IN NAVIGATE.XML FILE
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>    android:orientation="vertical"
>    android:layout_width="fill_parent"
>    android:layout_height="wrap_content">
>
>   <Spinner android:id="@+id/spinnerMain"
>        android:layout_width="fill_parent"
>        android:layout_height="wrap_content"
>        android:drawSelectorOnTop="true"
>    />
>       <Spinner android:id="@+id/spinnerNavigate"
>        android:layout_width="fill_parent"
>        android:layout_height="wrap_content"
>        android:drawSelectorOnTop="true"
>    />
>
>
>
> </LinearLayout>
> I JUST WANT TO AVOID REWRITING THE CODE FOR  FIRST SPINNER      CAN U
> SUGGEST ME THE WAY HOW TO DO THIS.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to