i was trying to use switch statement for the radiobutton but i am etting errors when i run it. can somebody please help me out. i have pasted my android code below. please help if you know the answer. thanks a lot.
package apt.tutorial;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.R;
public class LunchtimeActivity extends Activity {
Restaurant r=new Restaurant();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button save=(Button)findViewById(R.id.button1);
save.setOnClickListener(onSave);
}
private View.OnClickListener onSave=new View.OnClickListener() {
public void onClick(View v) {
EditText name=(EditText)findViewById(R.id.text1);
EditText address=(EditText)findViewById(R.id.text2);
r.setName(name.getText().toString());
r.setAddress(address.getText().toString());
RadioGroup types=(RadioGroup)findViewById(R.id.types);
switch (types.GetCheckedRadiobuttonId()) {
case R.id.Sit-Down:
r.setType("Sit_Down");
break;
case R.id.Take-Out:
r.setType("Take_Out");
break;
case R.id.Delivery:
r.setType("Delivery");
break;
}
}
};
}