Professional Documents
Culture Documents
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:padding="20dp"
android:layout_margin="20dp"
android:background="@color/white"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Summary"
android:textAlignment="center"
android:textSize="20sp"/>
<TextView
android:id="@+id/textFirstName"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="First" />
<TextView
android:id="@+id/textLastName"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Last" />
<TextView
android:id="@+id/textGender"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Gender" />
<TextView
android:id="@+id/textEmail"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Email" />
<TextView
android:id="@+id/textAddress"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Address" />
<TextView
android:id="@+id/textUserName"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Username" />
<TextView
android:id="@+id/textPhoneNumber"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Phone" />
</LinearLayout>
</ScrollView>
5. Pada Activity2.java, tuliskan baris program berikut
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_2);
Bundle bundle = getIntent().getExtras();
String firstName = bundle.getString("firstName");
String lastName = bundle.getString("lastName");
String email = bundle.getString("email");
String address = bundle.getString("address");
String phoneNumber = bundle.getString("phoneNumber");
String username = bundle.getString("username");
String gender = bundle.getString("gender");
textFirstName = findViewById(R.id.textFirstName);
textLastName = findViewById(R.id.textLastName);
textEmail = findViewById(R.id.textEmail);
textAddress = findViewById(R.id.textAddress);
textPhoneNumber = findViewById(R.id.textPhoneNumber);
textUsername = findViewById(R.id.textUserName);
textGender = findViewById(R.id.textGender);
//Menampilkan teks
textFirstName.setText(firstName);
textLastName.setText(lastName);
textEmail.setText(email);
textAddress.setText(address);
textPhoneNumber.setText(phoneNumber);
textUsername.setText(username);
textGender.setText(gender);
}
}
6. Pada MainActivity.java, tuliskan baris program berikut
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import org.w3c.dom.Text;
//Variabel String
String textFirstName, textLastName, textGender, textEmail, textAddress,
textPhoneNumber, textUsername;
button = findViewById(R.id.buttonSignUp);
editTextFirstName = findViewById(R.id.textFirstName);
editTextLastName = findViewById(R.id.textLastName);
editTextEmail = findViewById(R.id.textEmail);
editTextAddress = findViewById(R.id.textAddress);
editTextPhoneNumber = findViewById(R.id.textPhoneNumber);
editTextUsername = findViewById(R.id.textUserName);
radioGroup = findViewById(R.id.radioGender);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
textFirstName = editTextFirstName.getText().toString();
textLastName = editTextLastName.getText().toString();
textEmail = editTextEmail.getText().toString();
textAddress = editTextAddress.getText().toString();
textPhoneNumber = editTextPhoneNumber.getText().toString();
textUsername = editTextUsername.getText().toString();
//Radio Button Male/Female
int selectedID = radioGroup.getCheckedRadioButtonId();
radioButton = findViewById(selectedID);
textGender = radioButton.getHint().toString();
startActivity(intent);
}
});
}
}