Java Code Examples for android.widget.Button#setLayoutParams()

The following examples show how to use android.widget.Button#setLayoutParams() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectButtonView.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void initView(int length) {
    LayoutParams layoutParams = new LayoutParams(-1, -1);
    LinearLayout layout = new LinearLayout(this.mContext);
    layout.setLayoutParams(layoutParams);
    layout.setOrientation(0);
    this.buttons = new Button[length];
    this.length = length;
    for (int i = 0; i < length; i++) {
        LayoutParams btnLayoutParams = new LayoutParams(DensityUtil.dip2px(this.mContext, 13.0f), DensityUtil.dip2px(this.mContext, 3.0f));
        Button button = new Button(this.mContext);
        button.setBackgroundResource(R.drawable.host_main_btn_selected);
        btnLayoutParams.leftMargin = DensityUtil.dip2px(this.mContext, 6.0f);
        button.setLayoutParams(btnLayoutParams);
        this.buttons[i] = button;
        layout.addView(button);
    }
    addView(layout);
}
 
Example 2
Source File: HttpActivity.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitData() {
    mTitle.setText("Http test");
    String[] bttxt = getResources().getStringArray(R.array.http_list);
    if (bttxt != null) {
        for (int i = 0; i < bttxt.length; i++) {
            Button bt = new Button(this);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            int margin = getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin);
            lp.setMargins(margin, margin, margin, margin);
            bt.setId(i);
            bt.setText(bttxt[i]);
            bt.setOnClickListener(this);
            bt.setLayoutParams(lp);
            mContainer.addView(bt);
        }
    }
}
 
Example 3
Source File: MaterialDialog.java    From pius1 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
        * set positive button
        *
        * @param text the name of button
        */
       public void setPositiveButton(String text, final View.OnClickListener listener)
{
           Button button = new Button(mContext);
           LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
	LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
           button.setLayoutParams(params);
           button.setBackgroundResource(R.drawable.material_card);
           button.setTextColor(Color.argb(255, 35, 159, 242));
           button.setText(text);
           button.setGravity(Gravity.CENTER);
           button.setTextSize(14);
           button.setPadding(dip2px(12), 0, dip2px(32), dip2px(BUTTON_BOTTOM));
           button.setOnClickListener(listener);
           mButtonLayout.addView(button);
       }
 
Example 4
Source File: MaterialDialog.java    From pius1 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
        * set negative button
        *
        * @param text the name of button
        */
       public void setNegativeButton(String text, final View.OnClickListener listener)
{
           Button button = new Button(mContext);
           LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
	LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
           button.setLayoutParams(params);
           button.setBackgroundResource(R.drawable.material_card);
           button.setText(text);
           button.setTextColor(Color.argb(222, 0, 0, 0));
           button.setTextSize(14);
           button.setGravity(Gravity.CENTER);
           button.setPadding(0, 0, 0, dip2px(8));
           button.setOnClickListener(listener);
           if (mButtonLayout.getChildCount() > 0)
    {
               params.setMargins(20, 0, 10, dip2px(BUTTON_BOTTOM));
               button.setLayoutParams(params);
               mButtonLayout.addView(button, 1);
           }
    else
    {
               button.setLayoutParams(params);
               mButtonLayout.addView(button);
           }
       }
 
Example 5
Source File: CTInboxBaseMessageViewHolder.java    From clevertap-android-sdk with MIT License 5 votes vote down vote up
void hideOneButton(Button mainButton, Button secondaryButton, Button tertiaryButton){
    tertiaryButton.setVisibility(View.GONE);
    LinearLayout.LayoutParams mainLayoutParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT,3);
    mainButton.setLayoutParams(mainLayoutParams);
    LinearLayout.LayoutParams secondaryLayoutParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT,3);
    secondaryButton.setLayoutParams(secondaryLayoutParams);
    LinearLayout.LayoutParams tertiaryLayoutParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT,0);
    tertiaryButton.setLayoutParams(tertiaryLayoutParams);
}
 
Example 6
Source File: ButtonViewSample.java    From pixate-freestyle-android with Apache License 2.0 5 votes vote down vote up
@Override
public void createViews(Context context, ViewGroup layout) {
    Button button = new Button(context);
    button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));
    button.setText("Click Me!");
    PixateFreestyle.setStyleClass(button, "myButton");
    layout.addView(button);

    addView(button);
}
 
Example 7
Source File: MainActivity.java    From video-tutorial-code with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void populateButtons() {
   	TableLayout table = (TableLayout) findViewById(R.id.tableForButtons);
   	
   	for (int row = 0; row < NUM_ROWS; row++) {
   		TableRow tableRow = new TableRow(this);
   		tableRow.setLayoutParams(new TableLayout.LayoutParams(
   				TableLayout.LayoutParams.MATCH_PARENT,
   				TableLayout.LayoutParams.MATCH_PARENT,
   				1.0f));
   		table.addView(tableRow);
   		
   		for (int col = 0; col < NUM_COLS; col++){ 
   			final int FINAL_COL = col;
   			final int FINAL_ROW = row;
   			
   			Button button = new Button(this);
   			button.setLayoutParams(new TableRow.LayoutParams(
   					TableRow.LayoutParams.MATCH_PARENT,
   					TableRow.LayoutParams.MATCH_PARENT,
   					1.0f));
   			
   			button.setText("" + col + "," + row);
   			
   			// Make text not clip on small buttons
   			button.setPadding(0, 0, 0, 0);
   			
   			button.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					gridButtonClicked(FINAL_COL, FINAL_ROW);
				}
			});
   			
   			tableRow.addView(button);
   			buttons[row][col] = button;
   		}
   	}
}
 
Example 8
Source File: CTInAppBasePartialNativeFragment.java    From clevertap-android-sdk with MIT License 5 votes vote down vote up
void hideSecondaryButton(Button mainButton, Button secondaryButton){
    secondaryButton.setVisibility(View.GONE);
    LinearLayout.LayoutParams mainLayoutParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT,2);
    mainButton.setLayoutParams(mainLayoutParams);
    LinearLayout.LayoutParams secondaryLayoutParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT,0);
    secondaryButton.setLayoutParams(secondaryLayoutParams);
}
 
Example 9
Source File: AnimationLayoutChangesFragment.java    From AndroidAll with Apache License 2.0 5 votes vote down vote up
private void addButtonView() {
    i++;
    Button button = new Button(getActivity());
    button.setText("button" + i);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    button.setLayoutParams(params);
    layoutTransitionGroup.addView(button, 0);
}
 
Example 10
Source File: MainActivity.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
private void addDemo(String demoName, Class<? extends Activity> activityClass) {
    Button b = new Button(this);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    b.setLayoutParams(layoutParams);
    b.setText(demoName);
    b.setTag(activityClass);
    b.setOnClickListener(this);
    mListView.addView(b);
}
 
Example 11
Source File: MainActivity.java    From android-ui-toolkit-demos with Apache License 2.0 5 votes vote down vote up
private Button createMaterialMotionButton(String label,
        final float cx1, final float cy1, final float cx2, final float cy2,
        float weight, final ControlPointCallback callback) {
    Button button = new Button(this);
    LayoutParams params = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.weight = weight;
    button.setLayoutParams(params);
    button.setText("F out L in");
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Animate the control points to their new values
            final float oldCx1 = mVisualizer.getCx1();
            final float oldCy1 = mVisualizer.getCy1();
            final float oldCx2 = mVisualizer.getCx2();
            final float oldCy2 = mVisualizer.getCy2();
            ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(100);
            anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    float t = valueAnimator.getAnimatedFraction();
                    mVisualizer.setCubicInterpolator(oldCx1 + t * (cx1 - oldCx1),
                            oldCy1 + t * (cy1 - oldCy1),
                            oldCx2 + t * (cx2 - oldCx2),
                            oldCy2 + t * (cy2 - oldCy2), callback);
                }
            });
            anim.start();
        }
    });
    return button;
}
 
Example 12
Source File: MasterFragment.java    From AdvancedMaterialDrawer with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    drawer = (MaterialNavigationDrawer) getActivity();

    Button button = new Button(this.getActivity());
    button.setText("start child fragment");
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    button.setLayoutParams(params);
    button.setGravity(Gravity.CENTER);


    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawer.changeFragment(new ChildFragment(), "Child Title");
            // normally currentSection gets unselect on setCustomFragment call
            // in the next relase, i will add a new method without unselect
            drawer.getCurrentSectionFragment().select();

            // call on current git head. drawer.getCurrentSectionFragment().select(); is not needed
            // drawer.setCustomFragment(drawer.getCurrentSectionFragment().getTargetFragment(), drawer.getCurrentSectionFragment().getFragmentTitle(), true, false);
        }
    });

    return button;
}
 
Example 13
Source File: OnekeyShare.java    From AndroidLinkup with GNU General Public License v2.0 4 votes vote down vote up
private void initPageView() {
    flPage = new FrameLayout(getContext());
    flPage.setOnClickListener(this);

    // 宫格列表的容器,为了“下对齐”,在外部包含了一个FrameLayout
    LinearLayout llPage = new LinearLayout(getContext()) {
        public boolean onTouchEvent(MotionEvent event) {
            return true;
        }
    };
    llPage.setOrientation(LinearLayout.VERTICAL);
    int resId = getBitmapRes(getContext(), "share_vp_back");
    if (resId > 0) {
        llPage.setBackgroundResource(resId);
    }
    FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpLl.gravity = Gravity.BOTTOM;
    llPage.setLayoutParams(lpLl);
    flPage.addView(llPage);

    // 宫格列表
    grid = new PlatformGridView(getContext());
    grid.setEditPageBackground(bgView);
    LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    grid.setLayoutParams(lpWg);
    llPage.addView(grid);

    // 取消按钮
    btnCancel = new Button(getContext());
    btnCancel.setTextColor(0xffffffff);
    btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    resId = getStringRes(getContext(), "cancel");
    if (resId > 0) {
        btnCancel.setText(resId);
    }
    btnCancel.setPadding(0, 0, 0, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 5));
    resId = getBitmapRes(getContext(), "btn_cancel_back");
    if (resId > 0) {
        btnCancel.setBackgroundResource(resId);
    }
    LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 45));
    int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
    lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
    btnCancel.setLayoutParams(lpBtn);
    llPage.addView(btnCancel);
}
 
Example 14
Source File: HeaderFooterActivity.java    From CommonAdapter with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    recyclerView = new RecyclerView(this);
    LayoutUtil.setContentView(this, recyclerView);

    layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    layoutManager1 = new GridLayoutManager(this, 2);
    layoutManager2 = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);

    data.addAll(DataManager.loadData(getBaseContext()));

    final CommonRcvAdapter<DemoModel> adapter = initAdapter();

    wrapper = new RcvAdapterWrapper(adapter, recyclerView.getLayoutManager());

    final Button header = new Button(this);
    header.setText("Header\n\n (click to add)");
    header.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, 300));

    final Button footer = new Button(this);
    footer.setText("footer");

    wrapper.setHeaderView(header);
    wrapper.setFooterView(null);

    final Button empty = new Button(this);
    empty.setBackgroundColor(Color.RED);
    empty.setText("empty text");
    wrapper.setEmptyView(empty, recyclerView);

    recyclerView.setAdapter(wrapper);
    
    handItemClick();

    recyclerView.postDelayed(new Runnable() {
        @Override
        public void run() {
            data.reset(DataManager.loadData(getBaseContext(),10));
            wrapper.setFooterView(footer);
        }
    }, 1000);
}
 
Example 15
Source File: DirectoryChooserDialog.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private AlertDialog.Builder createDirectoryChooserDialog(String title, List<String> listItems,
                                                         DialogInterface.OnClickListener onClickListener) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(m_context);

    // Create custom view for AlertDialog title containing
    // current directory TextView and possible 'New folder' button.
    // Current directory TextView allows long directory path to be wrapped to multiple lines.
    LinearLayout titleLayout = new LinearLayout(m_context);
    titleLayout.setOrientation(LinearLayout.VERTICAL);

    m_titleView = new TextView(m_context);
    m_titleView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    m_titleView.setTextAppearance(m_context, android.R.style.TextAppearance_Large);
    m_titleView.setTextColor(m_context.getResources().getColor(android.R.color.white));
    m_titleView.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    m_titleView.setText(title);

    Button newDirButton = new Button(m_context);
    newDirButton.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    newDirButton.setText(m_context.getString(R.string.new_folder));
    newDirButton.setOnClickListener(v -> {
        final EditText input = new EditText(m_context);

        // Show new folder name input dialog
        new AlertDialog.Builder(m_context).
            setTitle("New folder name").
            setView(input).setPositiveButton(m_context.getString(R.string.global_ok), (dialog, whichButton) -> {
            Editable newDir = input.getText();
            String newDirName = newDir.toString();
            // Create new directory
            if (createSubDir(m_dir + "/" + newDirName)) {
                // Navigate into the new directory
                m_dir += "/" + newDirName;
                updateDirectory();
            } else {
                Toast.makeText(
                    m_context, "Failed to create '" + newDirName +
                        "' folder", Toast.LENGTH_SHORT).show();
            }
        }).setNegativeButton(m_context.getString(R.string.global_cancel), null).show();
    });

    if (!m_isNewFolderEnabled) {
        newDirButton.setVisibility(View.GONE);
    }

    titleLayout.addView(m_titleView);
    titleLayout.addView(newDirButton);

    dialogBuilder.setCustomTitle(titleLayout);

    m_listAdapter = createListAdapter(listItems);

    dialogBuilder.setSingleChoiceItems(m_listAdapter, -1, onClickListener);
    dialogBuilder.setCancelable(false);

    return dialogBuilder;
}
 
Example 16
Source File: OnekeyShare.java    From WeCenterMobile-Android with GNU General Public License v2.0 4 votes vote down vote up
private void initPageView() {
	flPage = new FrameLayout(getContext());
	flPage.setOnClickListener(this);

	// 宫格列表的容器,为了“下对齐”,在外部包含了一个FrameLayout
	LinearLayout llPage = new LinearLayout(getContext()) {
		public boolean onTouchEvent(MotionEvent event) {
			return true;
		}
	};
	llPage.setOrientation(LinearLayout.VERTICAL);
	int resId = getBitmapRes(getContext(), "share_vp_back");
	if (resId > 0) {
		llPage.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpLl.gravity = Gravity.BOTTOM;
	llPage.setLayoutParams(lpLl);
	flPage.addView(llPage);

	// 宫格列表
	grid = new PlatformGridView(getContext());
	grid.setEditPageBackground(bgView);
	LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	grid.setLayoutParams(lpWg);
	llPage.addView(grid);

	// 取消按钮
	btnCancel = new Button(getContext());
	btnCancel.setTextColor(0xffffffff);
	btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
	resId = getStringRes(getContext(), "cancel");
	if (resId > 0) {
		btnCancel.setText(resId);
	}
	btnCancel.setPadding(0, 0, 0, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 5));
	resId = getBitmapRes(getContext(), "btn_cancel_back");
	if (resId > 0) {
		btnCancel.setBackgroundResource(resId);
	}
	LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 45));
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
	lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
	btnCancel.setLayoutParams(lpBtn);
	llPage.addView(btnCancel);
}
 
Example 17
Source File: Settings.java    From Hangar with GNU General Public License v3.0 4 votes vote down vote up
protected void setupButton(Button button, LinearLayout.LayoutParams params) {
    button.setSingleLine(false);
    button.setAllCaps(true);
    button.setLayoutParams(params);
}
 
Example 18
Source File: OnekeyShare.java    From ShareSDKShareDifMsgDemo-Android with MIT License 4 votes vote down vote up
private void initPageView() {
	flPage = new FrameLayout(getContext());
	flPage.setOnClickListener(this);

	// 宫格列表的容器,为了“下对齐”,在外部包含了一个FrameLayout
	LinearLayout llPage = new LinearLayout(getContext()) {
		public boolean onTouchEvent(MotionEvent event) {
			return true;
		}
	};
	llPage.setOrientation(LinearLayout.VERTICAL);
	int resId = getBitmapRes(getContext(), "share_vp_back");
	if (resId > 0) {
		llPage.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpLl.gravity = Gravity.BOTTOM;
	llPage.setLayoutParams(lpLl);
	flPage.addView(llPage);

	// 宫格列表
	grid = new PlatformGridView(getContext());
	grid.setEditPageBackground(bgView);
	LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	grid.setLayoutParams(lpWg);
	llPage.addView(grid);

	// 取消按钮
	btnCancel = new Button(getContext());
	btnCancel.setTextColor(0xffffffff);
	btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
	resId = getStringRes(getContext(), "cancel");
	if (resId > 0) {
		btnCancel.setText(resId);
	}
	btnCancel.setPadding(0, 0, 0, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 5));
	resId = getBitmapRes(getContext(), "btn_cancel_back");
	if (resId > 0) {
		btnCancel.setBackgroundResource(resId);
	}
	LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 45));
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
	lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
	btnCancel.setLayoutParams(lpBtn);
	llPage.addView(btnCancel);
}
 
Example 19
Source File: DynamicAlertController.java    From dynamic-support with Apache License 2.0 4 votes vote down vote up
private void centerButton(Button button) {
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) button.getLayoutParams();
    params.gravity = Gravity.CENTER_HORIZONTAL;
    params.weight = 0.5f;
    button.setLayoutParams(params);
}
 
Example 20
Source File: OnekeyShare.java    From -Android_ShareSDK_Example_Wechat with MIT License 4 votes vote down vote up
private void initPageView() {
	flPage = new FrameLayout(getContext());
	flPage.setOnClickListener(this);

	// container of the platform gridview
	LinearLayout llPage = new LinearLayout(getContext()) {
		public boolean onTouchEvent(MotionEvent event) {
			return true;
		}
	};
	llPage.setOrientation(LinearLayout.VERTICAL);
	int resId = getBitmapRes(getContext(), "share_vp_back");
	if (resId > 0) {
		llPage.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpLl.gravity = Gravity.BOTTOM;
	llPage.setLayoutParams(lpLl);
	flPage.addView(llPage);

	// gridview
	grid = new PlatformGridView(getContext());
	LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	grid.setLayoutParams(lpWg);
	llPage.addView(grid);

	// cancel button
	btnCancel = new Button(getContext());
	btnCancel.setTextColor(0xffffffff);
	btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
	resId = getStringRes(getContext(), "cancel");
	if (resId > 0) {
		btnCancel.setText(resId);
	}
	btnCancel.setPadding(0, 0, 0, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 5));
	resId = getBitmapRes(getContext(), "btn_cancel_back");
	if (resId > 0) {
		btnCancel.setBackgroundResource(resId);
	}
	LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 45));
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
	lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
	btnCancel.setLayoutParams(lpBtn);
	llPage.addView(btnCancel);
}