2013-09-21 5 views
0

코드 스 니펫 : 코드 위안드로이드 키보드가 TabActivity의 하위 활동에 나타나지 않습니다

public class home extends TabActivity implements OnTabChangeListener{ 

private static final String HOME_SPEC = ""; 
private static final String PROFILE_SPEC = ""; 
private static final String NEWPOST_SPEC = ""; 
private static final String SETTINGS_SPEC = ""; 
private TabHost tabHost; 
private TextView header; 
int s,c; 
private Typeface tf; 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.home); 

    tabHost = getTabHost(); 

    TabSpec newpostSpec = tabHost.newTabSpec(NEWPOST_SPEC); 
    newpostSpec.setIndicator(NEWPOST_SPEC, getResources().getDrawable(R.drawable.icon_post_tab)); 
    Intent newpostIntent = new Intent(home.this,NewPostActivity.class); 
    newpostSpec.setContent(newpostIntent); 

    tabHost.addTab(loginSpec); 
    tabHost.addTab(newpostSpec); 

    tabHost.setOnTabChangedListener(this); 
    for(int i=0;i<tabHost.getTabWidget().getChildCount();i++) 
     { 
      tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.TRANSPARENT); 

     } 

     } 

    @Override 
    public void onTabChanged(String tabId) { 
     // TODO Auto-generated method stub 
     for(int i=0;i<tabHost.getTabWidget().getChildCount();i++) 
     { 
      tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.TRANSPARENT); 
     } 

     tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.TRANSPARENT); 
    } 

} 

내가 내가 EDITTEXT를 클릭하면 내가 하나 개의 EditText &이 NewPostActivity에 TabActivity.Now을 위해 사용하고, 키보드하지 나타납니다 그 edittext에 쓰기. 그럼 키보드의 모양을 위해 무엇을해야합니까? 회신 해 주시기 바랍니다 ....

여기

답변

0
For showing the keyboard implicitly do like this 

// for showing the soft keyboard on click of edit text 
    InputMethodManager mgr = (InputMethodManager)  getSystemService(Context.INPUT_METHOD_SERVICE); 
    // only will trigger it if no physical keyboard is open 
    mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); 


and to hide the keyboard it when touched somewhere outside of the edit text. 

rel.setOnTouchListener(new OnTouchListener() { 

     @Override 
     public boolean onTouch(View v, MotionEvent event) { 

      InputMethodManager mgr = (InputMethodManager)  getSystemService(Context.INPUT_METHOD_SERVICE); 
      mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0); 
      return false; 
     } 
    }); 

확인해은 XML에있는 최고 배치는 응답

+0

덕분에 ...하지만 android2.3.6 버전은 작동하지 않습니다 .... 내가 직면하고 문제. .. android4.0에서 완벽하게 작동합니다 ... :( – dhrut

관련 문제