WEB开发网
开发学院手机开发Android 开发 Android 标签/TabActivity 深度研究 阅读

Android 标签/TabActivity 深度研究

 2010-06-19 17:46:00 来源:WEB开发网   
核心提示:}else if(id.equals(Tab4)){TextView tv = new TextView(activity);tv.setText("HelloTags!");tv.setGravity(Gravity.CENTER);layout.addView(tv);}return layou

}

else if(id.equals(Tab4)){

TextView tv = new TextView(activity);

tv.setText("HelloTags!");

tv.setGravity(Gravity.CENTER);

layout.addView(tv);

}

return layout;

}

}

public class CustomLayout implements TabHost.TabContentFactory {

Activity activity;

LayoutInflater inflaterHelper;

LinearLayout layout;

public CustomLayout (Activity a) {

activity = a;

inflaterHelper = a.getLayoutInflater();

}

/** {@inheritDoc} *///tag 标记各个标签

public View createTabContent(String tag) {

return addCustomView(tag);

}

public View addCustomView(String id){

layout = new LinearLayout(activity);

layout.setOrientation(LinearLayout.VERTICAL);

if(id.equals(Tab1)){

ImageView iv = new ImageView(activity);

iv.setImageResource(R.drawable.beijing_big);

layout.addView(iv,

new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));

}

else if(id.equals(Tab2)){

EditText edit = new EditText(activity);

layout.addView(edit,

new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));

Button btn = new Button(activity);

btn.setText("OK");

btn.setWidth(100);

layout.addView(btn,

new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));

RadioGroup rGroup = new RadioGroup(activity);

rGroup.setOrientation(LinearLayout.HORIZONTAL);

RadioButton radio1 = new RadioButton(activity);

radio1.setText("Radio A");

rGroup.addView(radio1);

RadioButton radio2 = new RadioButton(activity);

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:Android 标签 TabActivity

编辑录入:coldstar [复制链接] [打 印]
赞助商链接