-
-
Save mochadwi/865f47d9e6b8f68c8537b687692a4a8e to your computer and use it in GitHub Desktop.
Quiz App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.android.quizpsikologi; | |
import android.content.Intent; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.CheckBox; | |
import android.widget.Button; | |
import android.widget.CompoundButton; | |
import android.widget.TextView; | |
//import java.text.NumberFormat; | |
// | |
//import static android.R.attr.id; | |
//import static android.R.attr.name; | |
public class MainActivity extends AppCompatActivity { | |
//private int answer = 0; | |
private CheckBox agreementcheckbox; | |
private Button buttonnext1; | |
private int haschecked = 0; | |
private TextView testuji; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
agreementcheckbox = (CheckBox) findViewById(R.id.agreement); | |
buttonnext1 = (Button) findViewById(R.id.next1); | |
testuji = (TextView) findViewById(R.id.test); | |
buttonnext1.setOnClickListener(new View.OnClickListener() { | |
@Override public void onClick(View v) { | |
condition(agreementcheckbox.isChecked()); | |
} | |
}); | |
} | |
private void condition (boolean valid) | |
{ | |
if (valid) | |
{ | |
activity_main2(); // pindah ke Activity baru | |
} else { | |
Toast.makeText(this, "Silakan lengkapi form lebih dahulu!", Toast.LENGTH_SHORT); | |
} | |
} | |
private void activity_main2 () | |
{ | |
// testuji.setText("Masih Bisa"); | |
Intent activity_main2_Page = new Intent (this, Main2Activity.class); | |
startActivity(activity_main2_Page); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment