Main.Xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="User Name" />
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/username"/>
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/reset"
android:text="Reset Button"/>
</LinearLayout>
Activity(ResetExampleActivity )
package com.surya.resetvalues;
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;
public class ResetExampleActivity extends Activity {
EditText uname;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
uname =(EditText)findViewById(R.id.username);
Button reset=(Button)findViewById(R.id.reset);
reset.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
uname.setText(" ");
}
});
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="User Name" />
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/username"/>
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/reset"
android:text="Reset Button"/>
</LinearLayout>
Activity(ResetExampleActivity )
package com.surya.resetvalues;
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;
public class ResetExampleActivity extends Activity {
EditText uname;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
uname =(EditText)findViewById(R.id.username);
Button reset=(Button)findViewById(R.id.reset);
reset.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
uname.setText(" ");
}
});
}
}
No comments:
Post a Comment