2014-08-27 194 views
0

我有一個視圖(Tabhost),我想要顯示它,當我點擊一個按鈕,當我顯示thw Tabhost我隱藏軟鍵盤,如果我選擇相同的按鈕,我想顯示軟鍵盤並隱藏了Tabhost,我的鱈魚點擊波紋管,但它沒有像我想要的行爲..任何身體可以幫助!?隱藏視圖和顯示軟鍵盤

public void show_smily(View view) { // event habdler 
    EditText composer = (EditText) findViewById(R.id.message_composer); 
    InputMethodManager imm = (InputMethodManager)getSystemService(
      Context.INPUT_METHOD_SERVICE); 

    TabHost tabHost = (TabHost)findViewById(R.id.tabHost); 
    if(!tabHost.isShown()) { 
     imm.hideSoftInputFromWindow(composer.getWindowToken(),0); 
     tabHost.setVisibility(View.VISIBLE); 
    } 
    if(tabHost.isShown()) { 
     tabHost.setVisibility(View.GONE); 
     imm.showSoftInput(composer,0); 

    } 
} 

回答

0

好吧,我忘了之前的第二,如果把其他人,因此,第一codition真實,然後第二個是真實的,該應用程序是執行兩個街區...

public void show_smily(View view) { // event habdler 
EditText composer = (EditText) findViewById(R.id.message_composer); 
InputMethodManager imm = (InputMethodManager)getSystemService(
     Context.INPUT_METHOD_SERVICE); 

TabHost tabHost = (TabHost)findViewById(R.id.tabHost); 
if(!tabHost.isShown()) { 
    imm.hideSoftInputFromWindow(composer.getWindowToken(),0); 
    tabHost.setVisibility(View.VISIBLE); 
} 
else if(tabHost.isShown()) { // here was the problem 
    tabHost.setVisibility(View.GONE); 
    imm.showSoftInput(composer,0); 

} 

}