/* This is Simple Edit Text Demo of Android */
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal" >
<EditText
android:id="@+id/edtMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/tvViewMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/btnClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me" />
</LinearLayout>
EditTextDemoActivity.java
package com.edittextdemo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class EditTextDemoActivity extends Activity {
/** Called when the activity is first created. */
EditText edtMsg;
TextView tvViewMsg;
Button btnClick;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
edtMsg=(EditText)findViewById(R.id.edtMsg);
tvViewMsg=(TextView)findViewById(R.id.tvViewMsg);
tvViewMsg.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
TextView tempTv = (TextView)v;
tempTv.setText(edtMsg.getText());
}
});
btnClick=(Button)findViewById(R.id.btnClick);
btnClick.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
tvViewMsg.setText(edtMsg.getText());
}
});
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal" >
<EditText
android:id="@+id/edtMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/tvViewMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/btnClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me" />
</LinearLayout>
EditTextDemoActivity.java
package com.edittextdemo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class EditTextDemoActivity extends Activity {
/** Called when the activity is first created. */
EditText edtMsg;
TextView tvViewMsg;
Button btnClick;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
edtMsg=(EditText)findViewById(R.id.edtMsg);
tvViewMsg=(TextView)findViewById(R.id.tvViewMsg);
tvViewMsg.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
TextView tempTv = (TextView)v;
tempTv.setText(edtMsg.getText());
}
});
btnClick=(Button)findViewById(R.id.btnClick);
btnClick.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
tvViewMsg.setText(edtMsg.getText());
}
});
}
}
0 comments:
Post a Comment