0
편집 텍스트에서 텍스트를 그대로 가져 와서 TextView.But에 표시하고 싶을 때 getText()를 사용하여 텍스트를 얻을 때마다 한 줄에 텍스트가 표시됩니다. 멀티 라인 EditText에서 텍스트를 그대로 입력하는 방법. 나에게 안내 해줘?EditText 다중 행 텍스트를 Android로 검색 하시겠습니까?
편집 텍스트에서 텍스트를 그대로 가져 와서 TextView.But에 표시하고 싶을 때 getText()를 사용하여 텍스트를 얻을 때마다 한 줄에 텍스트가 표시됩니다. 멀티 라인 EditText에서 텍스트를 그대로 입력하는 방법. 나에게 안내 해줘?EditText 다중 행 텍스트를 Android로 검색 하시겠습니까?
Rajendar,
왜이 문제가 발생하는지 이해가되지 않습니다. EditText에서 텍스트를 가져올 때 줄 바꿈과 같은 "서식 지정"을 유지해야합니다.
예를 들어,이 코드를 사용해보십시오 (직접 테스트했습니다)!
main.xml에
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:id="@+id/et"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button
android:id="@+id/m_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button"
/>
</LinearLayout>
main.java
public class MainTest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.m_button);
button.setOnClickListener(btnListener);
}
//button listener
private OnClickListener btnListener = new OnClickListener() {
public void onClick (View view) {
EditText et = (EditText) findViewById(R.id.et);
String str = et.getText().toString();
Toast.makeText(getBaseContext(), str, Toast.LENGTH_LONG).show();
TextView tv = (TextView) findViewById(R.id.tv);
tv.setText(str);
}
};
}
토스트와 텍스트 뷰 줄 바꿈을 계속 둘. 너 스스로해볼 수있어.
아마도 코드를 게시하면 (적어도 관련된 비트) 우리는 당신을 도울 수 있습니다.