这是一个自定义对话框式菜单----选项卡
public class DialogActivity extends TabActivity{
private TabHost tabhost;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setMenuDialogAttrible(); //设置activity样式
createTabHost(); //创建选项卡
}
//设置菜单对话框 属性 [标题、透明度]
public void setMenuDialogAttrible(){
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
/*Window win = getWindow();
WindowManager.LayoutParams wlayout = win.getAttributes();
wlayout.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
wlayout.alpha = 0.5f; // 这句就是设置窗口里崆件的透明度的.0.0全透明.1.0不透明.
win.setAttributes(wlayout);*/
}
//创建选项卡
public void createTabHost(){
System.out.println("create TabHost");
tabhost = getTabHost();
LayoutInflater.from(this).inflate(R.layout.menu, tabhost.getTabContentView(), true);
tabhost.addTab(tabhost.newTabSpec("tab_server").setIndicator("SERVER",getResources().getDrawable(R.drawable.server)).setContent(R.id.widget_layout_server));
tabhost.addTab(tabhost.newTabSpec("tab_wifi").setIndicator("WIFI",getResources().getDrawable(R.drawable.wifi)).setContent(R.id.widget_layout_wifi));
tabhost.addTab(tabhost.newTabSpec("tab_terminal").setIndicator("TERMINAL",getResources().getDrawable(R.drawable.terminal)).setContent(R.id.widget_layout_terminal));
tabhost.addTab(tabhost.newTabSpec("tab_option").setIndicator("OPTION",getResources().getDrawable(R.drawable.option)).setContent(R.id.widget_layout_option));
tabhost.setCurrentTab(0);
tabhost.setOnTabChangedListener(new TabChangeListener());
}
class TabChangeListener implements OnTabChangeListener{
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
System.out.println("tabId: "+tabId);
if(tabId.equals("tab_server")){
}else if(tabId.equals("tab_wifi")){
}else if(tabId.equals("tab_terminal")){
}else if(tabId.equals("tab_option")){
}
}
}
}
AndroidManifest.xml配置
<activity android:label="@string/app_name" android:name=".DialogActivity" android:theme="@android:style/Theme.Dialog">
</activity>
menu.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:layout_width="fill_parent" android:layout_height="250dp">
<LinearLayout android:id="@+id/widget_layout_server"
android:layout_width="fill_parent" android:layout_height="fill_parent"
androidrientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow >
<TextView
android:id="@+id/textView2"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Server IP" />
<EditText
android:id="@+id/EditText_serverip"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="192.168.0.173" />
</TableRow>
<TableRow >
<TextView
android:id="@+id/textView3"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Client ID " />
<EditText
android:id="@+id/EditText01"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1001" />
</TableRow>
<TableRow >
<TextView
android:id="@+id/textView1"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Terminal ID" />
<EditText
android:id="@+id/edit_text"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3" />
</TableRow>
<TableRow >
<TextView
android:id="@+id/textView3"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="password" />
<EditText
android:id="@+id/EditText01"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textPassword"
android:password="true"
android:text="******" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/textView3"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="手动更新" />
<ToggleButton
android:id="@+id/toggleBtn_update"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ToggleButton" />
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout android:id="@+id/widget_layout_wifi"
android:layout_width="fill_parent" android:layout_height="fill_parent"
androidrientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow >
<TextView
android:id="@+id/wifi_textView2"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="WIFI" />
<ToggleButton
android:id="@+id/toggleBtn_wifi"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ToggleButton" />
</TableRow>
<TableRow >
<TextView
android:id="@+id/wifi_textView3"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="SSID" />
<EditText
android:id="@+id/wifi_EditText01"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="23456789abc" />
</TableRow>
<TableRow >
<TextView
android:id="@+id/wifi_textView1"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="模式" />
<EditText
android:id="@+id/wifi_edit_text"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="WEP" />
</TableRow>
<TableRow >
<TextView
android:id="@+id/wifi_textView3"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="加密方式 " />
<EditText
android:id="@+id/EditText01"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="64bit" />
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout android:id="@+id/widget_layout_terminal"
android:layout_width="fill_parent" android:layout_height="fill_parent"
androidrientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow >
<TextView
android:id="@+id/term_textView1"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="DHCP" />
<EditText
android:id="@+id/term_EditText_dhcp"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=" " />
</TableRow>
<TableRow >
<TextView
android:id="@+id/term_textView2"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="终端IP " />
<EditText
android:id="@+id/term_EditText_termIp"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=" " />
</TableRow>
<TableRow >
<TextView
android:id="@+id/term_textView3"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="DNS" />
<EditText
android:id="@+id/term_edit_text_dns"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
</TableRow>
<TableRow >
<TextView
android:id="@+id/term_textView4"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Gateway" />
<EditText
android:id="@+id/term_edit_text_gateway"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
</TableRow>
<TableRow >
<TextView
android:id="@+id/term_textView4"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="mac" />
<EditText
android:id="@+id/term_edit_text_mac"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout android:id="@+id/widget_layout_option"
android:layout_width="fill_parent" android:layout_height="fill_parent"
androidrientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow >
<TextView
android:id="@+id/option_textView1"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="FTP" />
<EditText
android:id="@+id/option_EditText01"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=" " />
</TableRow>
<TableRow >
<TextView
android:id="@+id/option_textView2"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="格式化 " />
<EditText
android:id="@+id/option_EditText02"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=" " />
</TableRow>
<TableRow >
<TextView
android:id="@+id/option_textView3"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="语言" />
<EditText
android:id="@+id/option_edit_text03"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
</TableRow>
<TableRow >
<TextView
android:id="@+id/option_textView4"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="版本" />
<EditText
android:id="@+id/option_edit_text04"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
</TableRow>
<TableRow >
<TextView
android:id="@+id/option_textView5"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="日期" />
<EditText
android:id="@+id/option_edit_date"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:text="" />
</TableRow>
</TableLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>