Hi I want to store the values which I am fetching from this code, I
have stated the problem where I think I can save the numbers, please
help. I have here copied the layout I want I am able to capture the
current phonebook and can display the phonebook, now I want to store
the numbers in particular values that I can later pass for Calling.
But I need this activity as a SubActivity which passes variable to
some other subactivity.

Thanks in Advance
NUBH

P.S. : The Code works fine, but its slow someone suggested to put the
methods outside the onCreate() please suggest.




The Layout:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:text="Please Save the Speed Dials"/>
    <ListView android:id="@+id/listView"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"/>

<TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:text="Number 1:"/>
<Spinner
         android:id="@+id/spinner"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" />
<TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:text="Number 2:"/>
<Spinner
         android:id="@+id/spinner1"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" />

<TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:text="Number 3:"/>
<Spinner
         android:id="@+id/spinner2"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" />
<TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:text="Number 4:"/>
<Spinner
         android:id="@+id/spinner3"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
          />
<TableRow android:layout_marginTop="10dip">
<Button android:text="Save"
         android:id="@+id/SaveBtn"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"/>
<Button android:text="Cancel"
         android:id="@+id/CancelBtn"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" />

</TableRow>

</TableLayout>

& the Code:

public class HelloSpinner extends Activity
{
        // Here we initiate the spinners and provide a result
        public void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                // We define what we want to show here
                //@SuppressWarnings("unused")
                //String[] PROJECTION = new String[]
                //{
                                //      People._ID, People.NAME
                //};
                Spinner spinner = (Spinner) findViewById(R.id.spinner);
                Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
                Spinner spinner2 = (Spinner) findViewById(R.id.spinner2);
                Spinner spinner3 = (Spinner) findViewById(R.id.spinner3);

                spinner.setOnItemSelectedListener(new
MyOnItemSelectedListener());
                Cursor cur = getContentResolver().query(People.CONTENT_URI,
null, null, null, null);
                SimpleCursorAdapter adapter3 = new
SimpleCursorAdapter(this,
                                android.R.layout.simple_spinner_item,
                                // Use a template
                                // that displays
a
                                // text view
                                cur,
                                // Give the cursor to the list adapter
                                new String[] {People.NAME},
                                // Map the NAME column in the
                                // people database to...
                                new int[] {android.R.id.text1});
                                //      The "text1" view defined in
                                // the XML template
 
adapter3.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                                spinner.setAdapter(adapter3);

                                spinner1.setOnItemSelectedListener(new
MyOnItemSelectedListener1());
                        Cursor cur1 =
getContentResolver().query(People.CONTENT_URI, null, null, null,
null);
                                SimpleCursorAdapter adapter2 = new
SimpleCursorAdapter(this,
                                                
android.R.layout.simple_spinner_item,
                                                // Use a template
                                                // that displays
a
                                                // text view
                                                cur1,
                                                // Give the cursor to the list 
adapter
                                                new String[] {People.NAME},
                                                // Map the NAME column in the
                                                // people database to...
                                                new int[] {android.R.id.text1});
                                                //      The "text1" view 
defined in
                                                // the XML template
 
adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                                                spinner1.setAdapter(adapter2);

                                spinner2.setOnItemSelectedListener(new
MyOnItemSelectedListener2());
                            Cursor cur3 =
getContentResolver().query(People.CONTENT_URI, null, null, null,
null);
                                SimpleCursorAdapter adapter1 = new
SimpleCursorAdapter(this,
 
android.R.layout.simple_spinner_item,
                                                // Use a template
                                                // that displays
a
                                                // text view
                                                cur3,
                                                // Give the cursor to the list
adapter
                                                new String[] {People.NAME},
                                                // Map the NAME column in the
                                                // people database to...
                                                new int[] {android.R.id.text1});
                                                //      The "text1" view 
defined in
                                                // the XML template
 
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                                                spinner2.setAdapter(adapter1);

                            spinner3.setOnItemSelectedListener(new
MyOnItemSelectedListener3());
                            Cursor cur4 =
getContentResolver().query(People.CONTENT_URI, null, null, null,
null);
                               SimpleCursorAdapter adapter = new
SimpleCursorAdapter(this,
 
android.R.layout.simple_spinner_item,
                                           // Use a template
                                           // that displays
a
                                           // text view
                                           cur4,
                                           // Give the cursor to the list
adapter
                                           new String[] {People.NAME},
                                           // Map the NAME column in the
                                           // people database to...
                                           new int[] {android.R.id.text1});
                                                //      The "text1" view 
defined in
                                                // the XML template
 
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                                                spinner3.setAdapter(adapter);

        } // The create method ends

                // This is method for first spinner
                public class MyOnItemSelectedListener implements
OnItemSelectedListener
                {
                        public void onItemSelected(AdapterView<?> parent,
                                        View view, int pos, long id)
                        {
                                //
                                        Toast.makeText(parent.getContext(),
                                        "The Person is " +
                                        
parent.getItemAtPosition(pos).toString(),
                                        Toast.LENGTH_LONG).show();
                        }
                        public void onNothingSelected(AdapterView<?> parent)
                        {
                                // Do nothing.
                        }
                }

                //      This is method for second spinner
                public class MyOnItemSelectedListener1 implements
OnItemSelectedListener
                {
                        public void onItemSelected(AdapterView<?> parent,
                                        View view, int pos, long id)
                        {
                                // The value saves here
                                Toast.makeText(parent.getContext(),
                                                "The Person is " +
                                                
parent.getItemAtPosition(pos).toString(),
                                                Toast.LENGTH_LONG).show();
                        }
                        public void onNothingSelected(AdapterView<?> parent)
                        {
                                // Do nothing.
                        }
                }

                // This is method for third spinner
                public class MyOnItemSelectedListener2 implements
OnItemSelectedListener
                {
                        public void onItemSelected(AdapterView<?> parent,
                                        View view, int pos, long id)
                        {
                                // The value saves here
                                                
Toast.makeText(parent.getContext(),
                                                                "The Person is 
" +
                                                                
parent.getItemAtPosition(pos).toString(),
                                                                
Toast.LENGTH_LONG).show();
                        }
                        public void onNothingSelected(AdapterView<?> parent)
                        {
                                // Do nothing.
                        }
                }

                // This is method for fourth spinner
                public class MyOnItemSelectedListener3 implements
OnItemSelectedListener
                {
                        public void onItemSelected(AdapterView<?> parent,
                                        View view, int pos, long id)
                        {
                                // The value saves here
                                                
Toast.makeText(parent.getContext(),
                                                                "The Person is 
" +
                                                                
parent.getItemAtPosition(pos).toString(),
                                                                
Toast.LENGTH_LONG).show();
                        }
                        public void onNothingSelected(AdapterView<?> parent)
                        {
                                // Do nothing.
                        }
                }

}// the class ends here

-- 
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to