Sunday, 17 November 2013

Responsi Pemmograman mobile


TOAST+CHECKBOX.

        cb1 = (CheckBox)findViewById(R.id.cbGanteng);
//cb1 variable untuk checkbox pertama
        cb1.setOnClickListener(new View.OnClickListener() {
                                               
                                                @Override
                                                public void onClick(View arg0) {
                                                                // TODO Auto-generated method stub
//coding untuk menampilkan toast ketika checkbox di klik
                                                                if(cb1.isChecked()){
                                                                                tampilPesan("Laki - laki");
                                                                }else{
                                                                                tampilPesan("Anda Bukan Laki - laki");
                                                                }
                                                }
                                });

 public void tampilPesan(String isiPesan){
//Untuk menampilkan toast pada checkbox
                                 Toast.makeText(getBaseContext(), isiPesan,Toast.LENGTH_SHORT);






RADIOBUTTON.
public class radiobtn extends Activity implements RadioGroup.OnCheckedChangeListener{
                //Deklarasi radiogroup yang sudah dibuat
                RadioGroup orientation;
                @Override
                protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.radiobtn);
    //orientation adalah radiogrup yang dibentuk untuk mengaktifkan fungsi vertical dan horizontal
        orientation=(RadioGroup) findViewById(R.id.orientation);
        orientation.setOnCheckedChangeListener(this);
 public void onCheckedChanged(RadioGroup group,int checkId){
                                 switch(checkId){
                                 case R.id.horizontal:
                                                 orientation.setOrientation(LinearLayout.HORIZONTAL);
                                                 break;
                                 case R.id.vertical:
                                                 orientation.setOrientation(LinearLayout.VERTICAL);
                                                 break;
                                 }







TAMPILGAMBAR(Multiple Layout).
 ImageButton startAct=(ImageButton)findViewById(R.id.imageButton1);
        startAct.setOnClickListener(new View.OnClickListener() {
                                               
                                                @Override
                                                public void onClick(View arg0) {
                                                                // TODO Auto-generated method stub
                                                                //metode untuk memanggil kelas lain
                                                                Intent myIntent=new Intent(getBaseContext(),MainActivity.class);
                                                                startActivity(myIntent);
                                                }
                                });
}
                 public void pindah2(View v){
                                Intent pindah2=new Intent(this,MainActivity.class);
                                startActivity(pindah2);
                    }



UNTUK MENGGANTI WARNA BACKGROUND DAN TULISAN:
DAPAT MEMASUKAN GAMBAR.PNG KEDALAM XXHDPI FOLDER ATAU MEMASUKAN STRING BARU DALAM STRING.XML

Output:






0 komentar:

Post a Comment

Note: only a member of this blog may post a comment.