Android-Edittext软键盘

Android-Edittext软键盘,android,android-layout,listview,android-softkeyboard,Android,Android Layout,Listview,Android Softkeyboard,我有一个带有编辑文本的列表视图;当我触摸EditText时,软键盘将出现,并且我已经输入了一些文本,这很好。但在输入文本后,按backspace按钮(而不是back按钮),活动将完成 为什么会这样?这里出了什么问题?我怎样才能解决这个问题? 请有人帮我找出这个谜语 在xml中 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res

我有一个带有编辑文本的
列表视图
;当我触摸
EditText
时,软键盘将出现,并且我已经输入了一些文本,这很好。但在输入文本后,按backspace按钮(而不是back按钮),活动将完成

为什么会这样?这里出了什么问题?我怎样才能解决这个问题? 请有人帮我找出这个谜语

在xml中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minLines="15"
        android:textColor="#000000"
        android:background="@drawable/back"
        />
    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Comments"
        android:textColor="#000000"
        android:visibility="gone"/>
    <TextView 
        android:id="@+id/notes_to_parents"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"/>

</LinearLayout>

在java中。 此for循环位于Listview onScroll操作的内部

for (int i = 0; i < daily_dairy_2.getChildCount(); i++) 
                {
LinearLayout layout = (LinearLayout) daily_dairy_2.getChildAt(i);
final EditText notes_to     = (EditText) layout.getChildAt(0);

}
for(int i=0;i

我知道这里我没有为edittext编写任何代码。如何处理此edittext。

您可以为edittext设置OnKeyListener,以便检测任何按键

editText.setOnKeyListener(new OnKeyListener() {                 
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            //You can identify which key pressed buy checking keyCode value with KeyEvent.KEYCODE_
             if(keyCode == KeyEvent.KEYCODE_DEL){  
                 //this is for backspace
                 }
        return false;       
            }
    });

这是代码句柄backspace按钮

为按backspace键创建自己的实现

是这样的

public final static int CodeDelete   = -5;
public class MyKeyboard extends InputMethodService
implements OnKeyboardActionListener{
public void onKey(int primaryCode, int[] keyCodes) {    
InputConnection ic = getCurrentInputConnection();
 switch(primaryCode){
    case CodeDelete :
        ic.deleteSurroundingText(1, 0);
        break;
在键盘的xml中:

        <Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete_dim">


发布您的logcat错误无崩溃,因此logcat中没有任何内容。放置您的代码,以便我们能够识别问题。在这里,我使用Listview并使用simpleadapter加载此布局。