android-ActionSheet
android-ActionSheet copied to clipboard
Scrolling Problem
How to make it scroll if the list is long..? please help..
OK i solved it by change your code a little bit.. i add a scrollview and the cancel button stay at the bottom.. can you take a look at this code.. and add to your library, so everyone can use it. TQ
private void createItems() {
String[] titles = getOtherButtonTitles();
RelativeLayout relativeLayout = new RelativeLayout(getActivity());
RelativeLayout.LayoutParams rll = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
relativeLayout.setLayoutParams(rll);
ScrollView scrollView = new ScrollView(getActivity());
RelativeLayout.LayoutParams ll = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
ll.addRule(RelativeLayout.ABOVE,ActionSheet.CANCEL_BUTTON_ID);
ll.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
scrollView.setLayoutParams(ll);
scrollView.setPadding(0,0,0,200);
LinearLayout linearLayout = new LinearLayout(getActivity());
LinearLayout.LayoutParams ll2 = new LinearLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setLayoutParams(ll2);
if (titles != null) {
for (int i = 0; i < titles.length; i++) {
Button bt = new Button(getActivity());
bt.setId(CANCEL_BUTTON_ID + i + 1);
bt.setOnClickListener(this);
bt.setBackgroundDrawable(getOtherButtonBg(titles, i));
bt.setText(titles[i]);
bt.setTextColor(mAttrs.otherButtonTextColor);
bt.setTextSize(TypedValue.COMPLEX_UNIT_PX, mAttrs.actionSheetTextSize);
if (i > 0) {
LinearLayout.LayoutParams params = createButtonLayoutParams();
params.topMargin = mAttrs.otherButtonSpacing;
linearLayout.addView(bt, params);
} else {
linearLayout.addView(bt);
}
}
}
scrollView.addView(linearLayout);
relativeLayout.addView(scrollView);
Button bt = new Button(getActivity());
bt.getPaint().setFakeBoldText(true);
bt.setTextSize(TypedValue.COMPLEX_UNIT_PX, mAttrs.actionSheetTextSize);
bt.setId(ActionSheet.CANCEL_BUTTON_ID);
bt.setBackgroundDrawable(mAttrs.cancelButtonBackground);
bt.setText(getCancelButtonTitle());
bt.setTextColor(mAttrs.cancelButtonTextColor);
bt.setOnClickListener(this);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
params.topMargin = mAttrs.cancelButtonMarginTop;
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
bt.setLayoutParams(params);
relativeLayout.addView(bt);
mPanel.addView(relativeLayout);
mPanel.setBackgroundDrawable(mAttrs.background);
mPanel.setPadding(mAttrs.padding, mAttrs.padding, mAttrs.padding, mAttrs.padding);
}