Hello,
Todays we will develop an application that contains two attributes "Button" and "EditText"
we will manage a simple activity that serves to display your sex,
you must press the "male" or "female" button and then display it in the "EditText",
Todays we will develop an application that contains two attributes "Button" and "EditText"
we will manage a simple activity that serves to display your sex,
you must press the "male" or "female" button and then display it in the "EditText",
the purpose of this article is to learn how to manage a Button,
<EditText android:id="@+id/EditText01"
android:layout_width="250dp"
android:layout_height="55dp"
android:textSize="20px"
android:editable="false"
android:cursorVisible="false">
</EditText>
android:layout_width="250dp"
android:layout_height="55dp"
android:textSize="20px"
android:editable="false"
android:cursorVisible="false">
</EditText>
<Button
android:text="Male"
android:id="@+id/button1"
android:layout_width="100dp"
android:layout_height="60dp"
android:textSize="20dp">
</Button>
android:text="Male"
android:id="@+id/button1"
android:layout_width="100dp"
android:layout_height="60dp"
android:textSize="20dp">
</Button>
<Button
android:text="Female"
android:id="@+id/button2"
android:layout_width="100dp"
android:layout_height="60dp"
android:textSize="20dp">
</Button>

package electro.droid;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class act1 extends Activity {
private EditText Screan;
private Button Male;
private Button Female;
private Button Male;
private Button Female;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Screan=(EditText)findViewById(R.id.EditText01);
Male = (Button) findViewById(R.id.button1);
Female= (Button) findViewById(R.id.button2);
Male.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Screan.setText("I'm a Man :)");
}
});
Female.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Screan.setText("I'm a Woman :)");
}
});
}
}
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Screan=(EditText)findViewById(R.id.EditText01);
Male = (Button) findViewById(R.id.button1);
Female= (Button) findViewById(R.id.button2);
Male.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Screan.setText("I'm a Man :)");
}
});
Female.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Screan.setText("I'm a Woman :)");
}
});
}
}






0 comments:
Post a Comment