2012-04-23 2 views
3

나는 탭 호스트를 가지고 있으며 각 탭마다 activitygroup이 있습니다.tabhost가있는 android activitygroup, 키보드가 보이지 않음

앱이 시작되고 editText를 누르면 키보드가 나옵니다. 자식 활동을 시작한 다음 키보드로 돌아 가면 기본 활동으로 돌아갑니다.

activitygroup의 주요 활동

ActivityGroupMeal.group.back(); 

그리고 다시 코드로 돌아갈하여 보조 Activity를

Intent i = new Intent(this, ShowAddFoodToSelection.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 

View view = ActivityGroupMeal.group.getLocalActivityManager().startActivity(DataParser.activityIDMeal, i).getDecorView(); 

ActivityGroupMeal.group.setContentView(view); 

내 코드를 시작하는 내 코드 :

public void back() { 
     try { 
      // if we set history.size() > 0 and we press back key on home 
      // activity 
      // and then on another activity we wont get back! 
      if (history.size() > 1) { 
       history.remove(history.size() - 1); 
       // call the super.setContent view! so set the real view 
       super.setContentView(history.get(history.size() - 1)); 
      } else { 

      } 
     } catch (Exception e) { 
      if (history.size() >= 0) 
       super.setContentView(history.get(0)); 
     } 
    } 

전 다음 코드로 editTextonClickListener을 설정하십시오.

private void keyboardShow() { 
     InputMethodManager inputManager = (InputMethodManager) ActivityGroupMeal.group.getSystemService(Context.INPUT_METHOD_SERVICE); 

     boolean test = inputManager.showSoftInput(editTextSearch, InputMethodManager.SHOW_IMPLICIT); 

     Toast.makeText(this, "show keyboard " + test, Toast.LENGTH_SHORT).show(); 
    } 

처음으로 true를 반환하고 내가 childactivity에서 돌아올 때 false를 반환합니다.

다른 탭을 클릭 한 다음 첫 번째 탭을 다시 클릭하면 editText를 클릭하면 다시 true가 반환됩니다.

편집 : 내가 임시 수정 프로그램을 가지고, 나는 editTextbox에 onClicklistener을 설정하고 내가 먼저 코드 탭을 전환해야 다시 childactivity에서 올 때 다음이 내가 코드

InputMethodManager inputManager = (InputMethodManager) ActivityGroupMeal.group 
       .getSystemService(Context.INPUT_METHOD_SERVICE); 

     // show keyboard , when it fails first switch tab and then try again 
     if (!inputManager.showSoftInput(null, InputMethodManager.SHOW_FORCED)) { 
      // switch from tab and back 
      // the keyboard wont show if we dont do this 
      ShowHomeTab parentActivity; 
      parentActivity = (ShowHomeTab) this.getParent().getParent(); 
      parentActivity.goToTab(DataParser.activityIDTracking); 
      parentActivity.goToTab(DataParser.activityIDShowFoodList); 

      inputManager.showSoftInput(null, InputMethodManager.SHOW_FORCED); 
     } 

와 키보드를 보여 키보드가 표시되기 전에 =/

누구든지 설명을 해 주시겠습니까?

+0

비슷한 문제가 있습니다. 해결 방법을 찾았습니까? 저에게 알려주세요. – kushaldsouza

+0

잘 모르겠습니다. 이 [ActivityGroup] (http://ericharlow.blogspot.in/2010/09/experience-multiple-android-activities.html)을 한 번 사용해보십시오. – Praveenkumar

+0

@ k9ty는이 문제에 대한 해결책을 찾았습니다 ????? – duggu

답변

1

당신은 EditText의 정의에 requestFocus /> 요소를 추가하려고 할 수 있습니다, 즉

<EditText android:id="@+id/edit_text" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:inputType="text" > 
     <requestFocus /> 
</EditText> 

내 응용 프로그램에서 requestFocus()

+0

오늘 시도해보고 작동하는지 알려주십시오. 고마워요 – kushaldsouza

+0

이것은 나를 위해 작동하지 않습니다. – kushaldsouza

4

를 호출하여 back() 방법, 요청 초점 도움이되지 않는 경우 어디 사용 된 활동 그룹, 아래에서 같은 문제를 해결하기 위해 코드를 사용했습니다.

YOUR_EDIT_TEXT.setOnEditorActionListener(new OnEditorActionListener() { 

      public boolean onEditorAction(TextView v, int actionId, 
        KeyEvent event) { 
       if (event != null&& (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { 
        InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
        in.hideSoftInputFromWindow(searchName 
          .getApplicationWindowToken(), 
          InputMethodManager.HIDE_NOT_ALWAYS); 
       } 
       return false; 
      } 
     }); 

괜찮아. 따라서이 코드 스 니펫을 사용해보십시오.

+0

이것을 시도했습니다. 키보드가 Android 4.0.4 펌웨어가있는 기기에 표시되지만 이전 펌웨어 버전 (2.3 이하)을 사용하는 기기에는 표시되지 않습니다. – kushaldsouza

+0

android : windowSoftInputMode = "stateVisible | adjustResize"를 매니페스트의 활동에 추가하고 확인합니다. –

+0

@PankajKumar가 동일한 문제에 직면하여 코드를 사용하지 않았습니까? 어떤 방법으로 문제를 해결할 수 있습니까? – duggu

관련 문제