我有自定義鍵盤或數字鍵盤的編輯文本我的問題是當我打開我的應用程序Android鍵盤自動出現我不希望發生這種情況 我的應用程序的想法很簡單,當我點擊編輯文本我的自定義鍵盤出現。 所以我怎麼能刪除的方式,如果我的應用程序手動取消它出現在第一 Android鍵盤就一直沒有出現,但正如我在重新開啓應用程式說再次出現,請大家幫忙如何移除在onCreate時自動出現的鍵盤?
public class BasicOnKeyboardActionListener implements OnKeyboardActionListener {
private Activity mTargetActivity;
/***
*
* @param targetActivity
* Activity a cui deve essere girato l'evento
* "pressione di un tasto sulla tastiera"
*/
public BasicOnKeyboardActionListener(Activity targetActivity) {
mTargetActivity = targetActivity;
}
@Override
public void swipeUp() {
// TODO Auto-generated method stub
}
@Override
public void swipeRight() {
// TODO Auto-generated method stub
}
@Override
public void swipeLeft() {
// TODO Auto-generated method stub
}
@Override
public void swipeDown() {
// TODO Auto-generated method stub
}
@Override
public void onText(CharSequence text) {
// TODO Auto-generated method stub
}
@Override
public void onRelease(int primaryCode) {
// TODO Auto-generated method stub
}
@Override
public void onPress(int primaryCode) {
// TODO Auto-generated method stub
}
@Override
public void onKey(int primaryCode, int[] keyCodes) {
long eventTime = System.currentTimeMillis();
KeyEvent event = new KeyEvent(eventTime, eventTime,
KeyEvent.ACTION_DOWN, primaryCode, 0, 0, 0, 0,
KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE);
mTargetActivity.dispatchKeyEvent(event);
}
CustomKeyboardView.class
public class CustomKeyboardView extends KeyboardView {
public CustomKeyboardView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void showWithAnimation(Animation animation) {
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
setVisibility(View.VISIBLE);
}
});
setAnimation(animation);
}
KeyboardWidgetTutorialActivity.class
public class KeyboardWidgetTutorialActivity extends Activity {
private CustomKeyboardView mKeyboardView;
private View mTargetView;
private Keyboard mKeyboard;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mKeyboard = new Keyboard(this, R.xml.keyboard);
mTargetView = (EditText) findViewById(R.id.target);
mTargetView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// Dobbiamo intercettare l'evento onTouch in modo da aprire la
// nostra tastiera e prevenire che venga aperta quella di
// Android
showKeyboardWithAnimation();
return true;
}
});
mKeyboardView = (CustomKeyboardView) findViewById(R.id.keyboard_view);
mKeyboardView.setKeyboard(mKeyboard);
mKeyboardView
.setOnKeyboardActionListener(new BasicOnKeyboardActionListener(
this));
}
/***
* Mostra la tastiera a schermo con una animazione di slide dal basso
*/
private void showKeyboardWithAnimation() {
if (mKeyboardView.getVisibility() == View.GONE) {
Animation animation = AnimationUtils
.loadAnimation(KeyboardWidgetTutorialActivity.this,
R.anim.slide_in_bottom);
mKeyboardView.showWithAnimation(animation);
}
}
這是主要的XML
<RelativeLayout android:id="@+id/LinearLayout1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:id="@+id/container" android:layout_alignParentTop="true"
android:layout_height="fill_parent" android:layout_above="@+id/keyboard_view">
<EditText android:layout_width="fill_parent" android:id="@+id/target"
android:layout_height="wrap_content" />
</LinearLayout>
<it.anddev.tutorial.CustomKeyboardView
android:id="@+id/keyboard_view" android:visibility="gone"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true"></it.anddev.tutorial.CustomKeyboardView>
感謝您的幫助可以幫助我簡單的事情 我想在底部右鍵是輸入或完成按鈕,當我按它不去像新的一行完成按鈕什麼是代碼而不是66,當我按下數字我不想要這個白色高光顯示或標誌 – CJS
你想去完成按鈕上的下一個編輯文本或想在同一個edittext文本 – Sarbjyot
年它是這樣的,但我沒有任何新的編輯文本 – CJS