2013-03-26 1 views
0

keyboard.xml 파일에서 'xml'폴더에 CustomKeyBoard를 정의하고이 keyboard.xml을 activity_layout.xml에 추가했습니다. 내 CustomkKeyboard가 내 활동이 시작될 때 자동으로로드되어야하지만, EditText를 만질 때로드되고 싶습니다. 내 코드는안드로이드에서 EditText를 건드리지 않고 사용자 정의 키보드를 자동으로로드

private CustomKeyboardView mKeyboardView; 
private View mTargetView; 
private Keyboard mKeyboard; 
mKeyboard = new Keyboard(this, R.xml.keyboard); 
    mTargetView = (EditText) findViewById(R.id.ed_2d_res); 
    mTargetView.setFocusable(true); 
    mTargetView.setOnTouchListener(new View.OnTouchListener() { 

     @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      showKeyboardWithAnimation(); 
      return true; 
     } 
    }); 

    mKeyboardView = (CustomKeyboardView) findViewById(R.id.keyboard_view); 
    mKeyboardView.setKeyboard(mKeyboard); 
    mKeyboardView.setOnKeyboardActionListener(new BasicOnKeyboardActionListener(this)); 
} 

private void showKeyboardWithAnimation() { 
    if (mKeyboardView.getVisibility() == View.GONE) { 
     Animation animation = AnimationUtils.loadAnimation(Add2d.this, R.anim.slide_in_bottom); 
     mKeyboardView.showWithAnimation(animation); 
    } 
} 

edittext를 터치하지 않고 사용자 지정 키보드를로드 할 수있는 방법이 있습니까?

+0

onCreate()에서 직접'showKeyboardWithAnimation(); '을 호출 하시겠습니까? –

답변

0

당신이에서 onCreate에서 showKeyboardWithAnimation()() 활동의 방법을 호출 할 수 있습니다 당신은 또한 edittext.requestfocus()를 호출해야

+0

이것은 도움이되지 못했습니다. – Bangaram

0

애니메이션은 포커스를 가진 뷰 시작합니다. onWindowFocusChanged (boolean hasFocus)를 오버라이드 (override)합니다.

+0

정말 고마워요. 많이 도와 줬어. – Bangaram

관련 문제