FileDocCategorySizeDatePackage
ListSetSelection.javaAPI DocAndroid 5.1 API2181Thu Mar 12 22:22:12 GMT 2015android.widget.listview

ListSetSelection

public class ListSetSelection extends android.util.ListScenario
List of 1,000 items used to test calls to setSelection() in touch mode. Pressing the S key will call setSelection(0) on the list.

Fields Summary
private android.widget.Button
mButton
Constructors Summary
Methods Summary
public booleandispatchKeyEvent(android.view.KeyEvent event)

        if (event.getKeyCode() == KeyEvent.KEYCODE_S) {
            getListView().setSelection(0);
            return true;
        }

        return super.dispatchKeyEvent(event);
    
public android.widget.ButtongetButton()

        return mButton;
    
protected voidinit(Params params)

        params.setStackFromBottom(false)
                .setStartingSelectionPosition(-1)
                .setNumItems(1000)
                .setItemScreenSizeFactor(0.22);
    
protected voidonCreate(android.os.Bundle icicle)

        super.onCreate(icicle);

        mButton = new Button(this);
        mButton.setText("setSelection(0)");
        mButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                getListView().setSelection(0);
            }
        });

        getListViewContainer().addView(mButton, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT
        ));