Views_Gallery2_People

old/API_Demo 2010. 4. 20. 10:37

[Gallery2.java]

public class Gallery2 extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gallery_2);

        // Get a cursor with all people
        Cursor c = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
        startManagingCursor(c);
       
        SpinnerAdapter adapter = new SimpleCursorAdapter(this,
        // Use a template that displays a text view
                android.R.layout.simple_gallery_item,
                // Give the cursor to the list adatper
                c,
                // Map the NAME column in the people database to...
                new String[] {People.NAME},
                // The "text1" view defined in the XML template
                new int[] { android.R.id.text1 });

        Gallery g = (Gallery) findViewById(R.id.gallery);
        g.setAdapter(adapter);
    }

}


 

[gallery_2.xml]

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginBottom="10dip"
        android:text="@string/gallery_2_text"
    />

    <Gallery android:id="@+id/gallery"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:spacing="16dp"
    />

</LinearLayout>

'old > API_Demo' 카테고리의 다른 글

Views_Grid_Photo Grid  (0) 2010.04.20
Views_Grid_Icon Grid  (0) 2010.04.20
Views_Gallery_Photos  (0) 2010.04.20
Views_Focus_Internal Selection  (0) 2010.04.19
Views_Focus_Circular  (0) 2010.04.19
Posted by jazzlife
,