FileDocCategorySizeDatePackage
List12.javaAPI DocAndroid 1.5 API2367Wed May 06 22:41:08 BST 2009com.example.android.apis.view

List12

public class List12 extends android.app.ListActivity implements android.view.View.OnClickListener, android.view.View.OnKeyListener
Demonstrates the using a list view in transcript mode

Fields Summary
private android.widget.EditText
mUserText
private android.widget.ArrayAdapter
mAdapter
private ArrayList
mStrings
Constructors Summary
Methods Summary
public voidonClick(android.view.View v)

        sendText();
    
protected voidonCreate(android.os.Bundle savedInstanceState)

    
    
        
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.list_12);
        
        mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrings);
        
        setListAdapter(mAdapter);
        
        mUserText = (EditText) findViewById(R.id.userText);

        mUserText.setOnClickListener(this);
        mUserText.setOnKeyListener(this);
    
public booleanonKey(android.view.View v, int keyCode, android.view.KeyEvent event)

        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_CENTER:
                case KeyEvent.KEYCODE_ENTER:
                    sendText();
                    return true;
            }
        }
        return false;
    
private voidsendText()

        String text = mUserText.getText().toString();
        mAdapter.add(text);
        mUserText.setText(null);