- Beranda
- Komunitas
- Tech
- Programmer Forum
Bantuannya dong Mastah Android


TS
dong.kus91
Bantuannya dong Mastah Android
bagi mastah mastah di sini,ane minta tolong dong
ane lagi belajar bikin aplikasi android
ini tampilannya gan>>

tapi pas ane running kok eror ya aplikasinya >>

ini main xmlnya
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android: orientation="vertical" >
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android: orientation="vertical">
<EditText android:id="@+id/txtName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter your Name here"
android:textColor="#cccccc"/>
<EditText android:id="@+id/txtPhone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter your phone number"
android:textColor="#cccccc"/>
</LinearLayout>
<RadioGroup android:id="@+id/group1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android: orientation="horizontal">
<RadioButton android:id="@+id/keju"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cheese"/>
<RadioButton android:id="@+id/keju2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2xCheese"/>
<RadioButton android:id="@+id/noKeju"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="None"/> </RadioGroup>
<RadioGroup android:id="@+id/group2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android: orientation="horizontal">
<RadioButton android:id="@+id/square"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Square"/>
<RadioButton android:id="@+id/round"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Round Pizza"/>
</RadioGroup>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android: orientation="vertical">
<CheckBox android:id="@+id/pep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="peperroni"/>
<CheckBox android:id="@+id/mus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mushroom"/>
<CheckBox android:id="@+id/veg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="veggies"/>
<CheckBox android:id="@+id/anc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Anchoives"/>
<Button android:id="@+id/butsms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>
</LinearLayout>
ini kodingan .JAVA nya gan
package com.hunt.android;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.view.View.*;;
public class AppOrderActivity extends Activity {
/** Called when the activity is first created. */
EditText name;
EditText phone;
RadioGroup group1;
RadioGroup group2;
RadioButton keju;
RadioButton keju2;
RadioButton none;
RadioButton square;
RadioButton round;
CheckBox pep;
CheckBox mus;
CheckBox veg;
CheckBox anc;
Button sms;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
name = (EditText) findViewById(R.id.txtName);
phone = (EditText) findViewById(R.id.txtPhone);
group1 = (RadioGroup) findViewById(R.id.group1);
group2 = (RadioGroup) findViewById(R.id.group2);
keju = (RadioButton) findViewById(R.id.keju);
keju2 = (RadioButton) findViewById(R.id.keju2);
none = (RadioButton) findViewById(R.id.noKeju);
square = (RadioButton) findViewById(R.id.square);
round = (RadioButton) findViewById(R.id.round);
pep = (CheckBox) findViewById(R.id.pep);
mus = (CheckBox) findViewById(R.id.mus);
veg = (CheckBox) findViewById(R.id.veg);
anc = (CheckBox) findViewById(R.id.anc);
sms = (Button) findViewById(R.id.butsms);
sms.setOnClickListener(new OnClickListener(){
public void onClick(View v){
if(pep.isChecked()==false && mus.isChecked() == false && veg.isChecked() ==false && anc.isChecked() ==false ){
Toast.makeText(AppOrderActivity.this, "harap Pilih jenis Pizza", 1).show();
}
String msg=""; msg=msg+" Topping=";
int radio1= group1.getCheckedRadioButtonId(),radio2=group2.getCheckedRadioButtonId();
if (keju.getId()==radio1){ msg=msg+"keju ";
}
else if (keju2.getId()==radio1){
msg=msg+"2xkeju ";
}
else if (none.getId()==radio1){
msg=msg+"tanpa keju ";
}
msg=msg+" Bentuk=";
if (square.getId()==radio2){
msg=msg+"bentuk kotak ";
}
else if (round.getId()==radio2){
msg=msg+"bentuk bundar ";
} msg=msg+" jenis=";
if (pep.isChecked()){
msg=msg+"peperoni ";
}
if (mus.isChecked()){
msg=msg+"mushroom ";
}
if (veg.isChecked()){
msg=msg+"Veggie ";
}
if (anc.isChecked()){
msg=msg+"anchoives ";
}
Toast.makeText(AppOrderActivity.this, "Nama="+name.getText().toString()+ " No="+ phone.getText().toString()+ ""+msg, 1).show();
}
});
}
}
mohon koreksinya ya mastah..
ane lagi belajar bikin aplikasi android
ini tampilannya gan>>
Quote:

tapi pas ane running kok eror ya aplikasinya >>
Quote:

ini main xmlnya
Spoiler for main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android: orientation="vertical" >
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android: orientation="vertical">
<EditText android:id="@+id/txtName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter your Name here"
android:textColor="#cccccc"/>
<EditText android:id="@+id/txtPhone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter your phone number"
android:textColor="#cccccc"/>
</LinearLayout>
<RadioGroup android:id="@+id/group1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android: orientation="horizontal">
<RadioButton android:id="@+id/keju"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cheese"/>
<RadioButton android:id="@+id/keju2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2xCheese"/>
<RadioButton android:id="@+id/noKeju"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="None"/> </RadioGroup>
<RadioGroup android:id="@+id/group2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android: orientation="horizontal">
<RadioButton android:id="@+id/square"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Square"/>
<RadioButton android:id="@+id/round"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Round Pizza"/>
</RadioGroup>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android: orientation="vertical">
<CheckBox android:id="@+id/pep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="peperroni"/>
<CheckBox android:id="@+id/mus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mushroom"/>
<CheckBox android:id="@+id/veg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="veggies"/>
<CheckBox android:id="@+id/anc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Anchoives"/>
<Button android:id="@+id/butsms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>
</LinearLayout>
ini kodingan .JAVA nya gan
Spoiler for .JAVA:
package com.hunt.android;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.view.View.*;;
public class AppOrderActivity extends Activity {
/** Called when the activity is first created. */
EditText name;
EditText phone;
RadioGroup group1;
RadioGroup group2;
RadioButton keju;
RadioButton keju2;
RadioButton none;
RadioButton square;
RadioButton round;
CheckBox pep;
CheckBox mus;
CheckBox veg;
CheckBox anc;
Button sms;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
name = (EditText) findViewById(R.id.txtName);
phone = (EditText) findViewById(R.id.txtPhone);
group1 = (RadioGroup) findViewById(R.id.group1);
group2 = (RadioGroup) findViewById(R.id.group2);
keju = (RadioButton) findViewById(R.id.keju);
keju2 = (RadioButton) findViewById(R.id.keju2);
none = (RadioButton) findViewById(R.id.noKeju);
square = (RadioButton) findViewById(R.id.square);
round = (RadioButton) findViewById(R.id.round);
pep = (CheckBox) findViewById(R.id.pep);
mus = (CheckBox) findViewById(R.id.mus);
veg = (CheckBox) findViewById(R.id.veg);
anc = (CheckBox) findViewById(R.id.anc);
sms = (Button) findViewById(R.id.butsms);
sms.setOnClickListener(new OnClickListener(){
public void onClick(View v){
if(pep.isChecked()==false && mus.isChecked() == false && veg.isChecked() ==false && anc.isChecked() ==false ){
Toast.makeText(AppOrderActivity.this, "harap Pilih jenis Pizza", 1).show();
}
String msg=""; msg=msg+" Topping=";
int radio1= group1.getCheckedRadioButtonId(),radio2=group2.getCheckedRadioButtonId();
if (keju.getId()==radio1){ msg=msg+"keju ";
}
else if (keju2.getId()==radio1){
msg=msg+"2xkeju ";
}
else if (none.getId()==radio1){
msg=msg+"tanpa keju ";
}
msg=msg+" Bentuk=";
if (square.getId()==radio2){
msg=msg+"bentuk kotak ";
}
else if (round.getId()==radio2){
msg=msg+"bentuk bundar ";
} msg=msg+" jenis=";
if (pep.isChecked()){
msg=msg+"peperoni ";
}
if (mus.isChecked()){
msg=msg+"mushroom ";
}
if (veg.isChecked()){
msg=msg+"Veggie ";
}
if (anc.isChecked()){
msg=msg+"anchoives ";
}
Toast.makeText(AppOrderActivity.this, "Nama="+name.getText().toString()+ " No="+ phone.getText().toString()+ ""+msg, 1).show();
}
});
}
}
mohon koreksinya ya mastah..

Diubah oleh dong.kus91 15-03-2013 02:38
0
1.1K
Kutip
5
Balasan


Komentar yang asik ya
Urutan
Terbaru
Terlama


Komentar yang asik ya
Komunitas Pilihan