FileDocCategorySizeDatePackage
ListOfEditTexts.javaAPI DocAndroid 5.1 API4225Thu Mar 12 22:22:12 GMT 2015android.widget.focus

ListOfEditTexts

public class ListOfEditTexts extends android.app.Activity

Fields Summary
private int
mLinesPerEditText
private ListView
mListView
private LinearLayout
mLinearLayout
Constructors Summary
Methods Summary
java.lang.StringgetBody(java.lang.String line)

        StringBuilder sb = new StringBuilder((line.length() + 5) * mLinesPerEditText);
        for (int i = 0; i < mLinesPerEditText; i++) {
            sb.append(i + 1).append(' ").append(line);
            if (i < mLinesPerEditText - 1) {
                sb.append('\n"); // all but last line
            }
        }
        return sb.toString();
    
public ListViewgetListView()


       
        return mListView;
    
protected voidonCreate(android.os.Bundle icicle)

        super.onCreate(icicle);

        // create linear layout
        mLinearLayout = new LinearLayout(this);
        mLinearLayout.setOrientation(LinearLayout.VERTICAL);
        mLinearLayout.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        // add a button above
        Button buttonAbove = new Button(this);
        buttonAbove.setLayoutParams(
                new LinearLayout.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.WRAP_CONTENT));
        buttonAbove.setText("button above list");
        mLinearLayout.addView(buttonAbove);

        // add a list view to it
        mListView = new ListView(this);
        mListView.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        mListView.setDrawSelectorOnTop(false);
        mListView.setItemsCanFocus(true);
        mListView.setLayoutParams((new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                0,
                1f)));

        List<String> bodies = Lists.newArrayList(
                getBody("zero hello, my name is android"),
                getBody("one i'm a paranoid android"),
                getBody("two i robot.  huh huh."),
                getBody("three not the g-phone!"));

        mListView.setAdapter(new MyAdapter(this, bodies));
        mLinearLayout.addView(mListView);

        // add button below
        Button buttonBelow = new Button(this);
        buttonBelow.setLayoutParams(
                new LinearLayout.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.WRAP_CONTENT));
        buttonBelow.setText("button below list");
        mLinearLayout.addView(buttonBelow);
        
        setContentView(mLinearLayout);