Methods Summary |
---|
public android.widget.Button | getButton(int groupNum)
if (groupNum > mNumGroups) {
throw new IllegalArgumentException("groupNum > " + mNumGroups);
}
return (Button) mLinearLayout.getChildAt(2*groupNum);
|
public android.widget.LinearLayout | getLinearLayout()
return mLinearLayout;
|
public int | getNumButtons()
return mNumGroups;
|
public android.widget.ScrollView | getScrollView()
return mScrollView;
|
protected void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
setContentView(R.layout.scrollview_linear_layout);
// estimated ratio to get enough buttons so a couple are off screen
int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
mNumGroups = screenHeight / 30;
mScrollView = (ScrollView) findViewById(R.id.scrollView);
mLinearLayout = (LinearLayout) findViewById(R.id.layout);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
for (int i = 0; i < mNumGroups; i++) {
// want button to be first and last
if (i > 0) {
TextView textView = new TextView(this);
textView.setText("Text View " + i);
mLinearLayout.addView(textView, p);
}
Button button = new Button(this);
button.setText("Button " + (i + 1));
mLinearLayout.addView(button, p);
}
|