Set text to EditText
Description
The following code shows how to
Set text to EditText
.
Example
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
//from w w w. jav a 2s . c om
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/field"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:singleLine="false"
/>
</LinearLayout>
Java code.
package com.java2s.app;
//from ww w . j a va2 s. co m
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);
EditText fld=(EditText)findViewById(R.id.field);
fld.setText("java2s.com");
}
}