Java EditText会自动转到下一行,并键入类似whatsapp EditText的单词

Java EditText会自动转到下一行,并键入类似whatsapp EditText的单词,java,android,android-studio,android-edittext,android-textinputedittext,Java,Android,Android Studio,Android Edittext,Android Textinputedittext,EditText <android.support.v7.widget.AppCompatEditText android:id="@+id/itemEditText_id" android:layout_width="match_parent" android:layout_height="70dp" android:layout_marginTop="8dp" and

EditText

<android.support.v7.widget.AppCompatEditText
            android:id="@+id/itemEditText_id"
            android:layout_width="match_parent"
            android:layout_height="70dp"
            android:layout_marginTop="8dp"
            android:layout_marginStart="2dp"
            android:layout_marginEnd="4dp"
            android:lines="2"
            android:scrollHorizontally="false"
            android:maxLength="69"
            android:scrollbars="vertical"
            android:background="@drawable/round_border_edit_text"
            android:hint="Go ahead \nSend messge"
            android:inputType="textMultiLine|textLongMessage"
            android:textAppearance="@style/TextAppearance.AppCompat.Body2"
            android:maxLines="2"
            android:minLines="1"
            />

这是我的xml代码,如果需要在此处添加或删除某些内容,请告知。

我用来实现我想要的东西的java代码,比如whatsapp的editText,但它工作得不太好

final AppCompatEditText editText = holder.itemEditText;

        editText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {



                // if edittext has 10chars & this is not called yet, add new line
                if(editText.getText().length() == 34 && !isReached) {

                    editText.append("\n");
                    isReached = true;

                }
                // if edittext has less than 10chars & boolean has changed, reset
                if(editText.getText().length() < 34 && isReached) isReached = false;

                Log.d("char", "onTextChanged: "+charSequence);
                Log.d("i", "onTextChanged: "+i);
                Log.d("i1", "onTextChanged: "+i1);
                Log.d("i2", "onTextChanged: "+i2);

            }

            @Override
            public void afterTextChanged(Editable editable) {


            }
        });

    }
final appcompatiedittext=holder.itemEditText;
editText.addTextChangedListener(新的TextWatcher(){
@凌驾
更改前的公共无效(CharSequence CharSequence,int i,int i1,int i2){
}
@凌驾
public void onTextChanged(CharSequence CharSequence,int i,int i1,int i2){
//如果edittext有10chars&尚未调用,请添加新行
如果(editText.getText().length()==34&&!isReached){
editText.append(“\n”);
isReached=正确;
}
//如果edittext的字数小于10chars&布尔值已更改,请重置
如果(editText.getText().length()<34&&isReached)isReached=false;
Log.d(“char”、“onTextChanged:+charSequence”);
Log.d(“i”,“onTextChanged:+i”);
Log.d(“i1”,“onTextChanged:+i1”);
Log.d(“i2”,“onTextChanged:+i2”);
}
@凌驾
public void PostTextChanged(可编辑){
}
});
}
此代码无法按我的要求运行,或者您可以说我无法按我希望的editText方式进行编码。

我希望我的editText像Whatsapp的editText一样工作,就像当我键入某个内容,它到达editText内的图标时,光标会转到一个新的带有键入单词的行。在我的编辑文本中,文字位于ImageButton下面,我使用它作为发送图标。我不想让文字出现在发送图标下面。请帮忙。

图像按钮

 <android.support.v7.widget.AppCompatImageButton
            android:id="@+id/itemSendButton_id"
            android:layout_width="25dp"
            android:layout_height="20dp"
            android:layout_alignParentEnd="true"
            android:layout_centerVertical="true"
            android:layout_marginEnd="11dp"
            android:background="@color/colorFacebookBtnText"
            android:clickable="true"
            android:focusable="true"
            android:scaleType="fitCenter"
            android:src="@drawable/ic_send" />

我是编程新手,请帮助我,并提前表示感谢。使用此工具

et1.addTextChangedListener(new TextWatcher() {

public void onTextChanged(CharSequence s, int start,int before, int count) 
{
    // TODO Auto-generated method stub
    if(et1.getText().toString().length()==size)     //size as per your requirement
    {
        et2.requestFocus();
    }
}
public void beforeTextChanged(CharSequence s, int start,
                int count, int after) {
            // TODO Auto-generated method stub

}

public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
}

});

我不希望光标转到下一个编辑文本。我希望光标与键入的单词一起转到同一editText中的新行