RSS

IcsSpinner implementation using actionbarsherlock

19 Mar

1. In layout.xml define IcsSpinner as

<com.actionbarsherlock.internal.widget.IcsSpinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_margin="10sp"
android:layout_centerHorizontal="true"
android:textSize="18sp" />

2. In code behind initialize IcsSpinner as

IcsSpinner spinner = (IcsSpinner)findViewById(R.id.spinner);

3. Bind data to IcsSpinner like

ArrayAdapter adapter = new ArrayAdapter(this, R.layout.spinner_item, elements);
spinner.setAdapter(adapter);

4. Handle setOnItemSelectedListener as

spinner.setOnItemSelectedListener(new IcsAdapterView.OnItemSelectedListener(){
    @Override
    public void onItemSelected(IcsAdapterView<?> parent, View view, int position, long id){
    }
    @Override
    public void onNothingSelected(IcsAdapterView<?> parent){
    }
});

5. Don’t forget to add theme as

android:theme="@style/Theme.Sherlock"

in manifest.

Advertisements
 
Leave a comment

Posted by on March 19, 2014 in ActionBarSherlock

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: