Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Android getText() and setText()

XML code:

EditText    
android:layout_width="wrap_content"    
android:hint="Enter data"    
android:id="@+id/enterInput"    
android:layout_height="wrap_content" />
TextView    
android:layout_width="match_parent"    
android:hint="data is"    
android:id="@+id/viewInput"    
android:textSize="25dp"    
android:layout_height="wrap_content" />
Button    
android:layout_width="match_parent"    
android:text="View data"    
android:layout_margin="20dp"    
android:onClick="ShowOutput"    
android:layout_height="wrap_content" />


Java Code:

public class MainActivity extends AppCompatActivity {
private EditText getInput;
TextView setInput;

@Override protected Void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getInput=findViewById(R.id.enterInput);
setInput=findViewById(R.id.viewInput);

}
public void ShowOutput(View view){
String getinput=getInput.getText().toString();
setInput.setText(getinput);
}

}


This post first appeared on AR Programming, please read the originial post: here

Share the post

Android getText() and setText()

×

Subscribe to Ar Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×