lin = (LinearLayout) findViewById(R.id.drama_first_lin);
scrollView = (ScrollView) findViewById(R.id.scroll_view);
searchTv = (TextView) findViewById(R.id.searc);
searchTv.setOnClickListener(new SearchListener());
List<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 7; i++) {
list.add(i);
}
for (int i = 0; i < 3; i++) {
if (i == 0) {
RelativeLayout relativeLayout = new RelativeLayout(this);
LayoutParams parms = new RelativeLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
relativeLayout.setLayoutParams(parms);
TextView titleTv = new TextView(this);
LayoutParams titleParmas = new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
titleTv.setGravity(Gravity.CENTER);
titleTv.setText("日本音乐");
titleParmas.leftMargin = 10;
titleTv.setLayoutParams(titleParmas);
TextView moreTv = new TextView(this);
LayoutParams moreParams = new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
moreTv.setGravity(Gravity.CENTER);
moreTv.setText("更多");
moreParams.rightMargin = 20;
moreParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
moreTv.setLayoutParams(moreParams);
relativeLayout.addView(titleTv);
relativeLayout.addView(moreTv);
moreTv.setOnClickListener(new MoreClickListener());
DramaGridView grid = new DramaGridView(this);
grid.setNumColumns(2);
grid.setHorizontalSpacing(10);
grid.setVerticalSpacing(8);
grid.setAdapter(new DramaTypeAdapter(this, list, 330));
relativeLayout.setFocusable(true);
lin.addView(relativeLayout);
lin.addView(grid);
} else {
TextView titleTv = new TextView(this);
LayoutParams titleParmas = new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
titleTv.setGravity(Gravity.CENTER);
titleTv.setText("完美动画");
titleParmas.leftMargin = 10;
titleTv.setLayoutParams(titleParmas);
DramaGridView grid = new DramaGridView(this);
grid.setNumColumns(2);
grid.setHorizontalSpacing(10);
grid.setVerticalSpacing(8);
grid.setAdapter(new DramaTypeAdapter(this, list, 330));
lin.addView(titleTv);
lin.addView(grid);
}
}