
定义界面如图: 添加标题;改成一行5个;添加取消分享按钮。
实现方法:

添加标题和添加分享按钮:
在PlatformPage的onCreate()方法添加如下代码.

```
lp=newLinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,130);
lp.setMargins(0,0,0,0);
LinearLayoutbuttonLayout=newLinearLayout(activity);
buttonLayout.setBackgroundColor(Color.WHITE);
LinearLayout.LayoutParamslp2=newLinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,110);
lp2.setMargins(20,20,20,0);
TextViewtv=newTextView(activity);
tv.setGravity(Gravity.CENTER);
tv.setText("分享到");
tv.setTextSize(16);
tv.setTextColor(CommonUtil.getColor(R.color.title_bg));
tv.setBackgroundColor(Color.WHITE);
buttonLayout.addView(tv,lp2);
llPanel.addView(buttonLayout,lp);
```

lp=newLinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,150);
lp.setMargins(0,0,0,0);
LinearLayoutbuttonLayout2=newLinearLayout(activity);
buttonLayout2.setBackgroundColor(Color.WHITE);
LinearLayout.LayoutParamslp22=newLinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,150);
lp22.setMargins(0,0,0,0);
Buttonbutton2=newButton(activity);
button2.setText("取消分享");
button2.setTextSize(16);
button2.setGravity(Gravity.CENTER);
button2.setTextColor(CommonUtil.getColor(R.color.title_bg));
button2.setBackgroundColor(Color.WHITE);
button2.setOnClickListener(newOnClickListener(){
@Override
public voidonClick(Viewv){
//TODO Auto-generated method stub
finish();
}
});
buttonLayout2.addView(button2,lp22);
llPanel.addView(buttonLayout2,lp);
修改行数和列数:
在PlatformPageAdapterPort里修改两个参数。
// private static final int PAGE_SIZE_P = 12; //每一页显示的总数。原来的默认值 为 是3行4列共12个
private static final intPAGE_SIZE_P=5; //现改为5个
// private static final int LINE_SIZE_P = 4; //列数
private static final intLINE_SIZE_P=5; //现改为5列
总结:按照以上步骤修改完毕,即可达到如图的效果。很简单,其它的需求可以根据这个自己发挥!
网友评论