在我的应用程序中,用户选择一个单选按钮,指示他有多少玩家想要参加这项选择。然后将该号码发送到另一个活动以进行显示。如果可能的话,我怎样才能获取单选按钮的 id 并去掉“单选”部分,只留下整数 4-10?
package teamBuilder;
import com.jonahwitcig.team.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
public class CorrectedActivity extends Activity {
/** Called when the activity is first created. */
TextView player1, team1;
Button next;
RadioGroup RBGroup;
RadioButton RB4, RB5, RB6, RB7, RB8, RB9, RB10;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.players);
next = (Button) findViewById(R.id.next);
//the name of a textView i will be displaying a number in
team1 = (TextView) findViewById(R.id.team1);
RB4 = (RadioButton) findViewById(R.id.radio4);
RB5 = (RadioButton) findViewById(R.id.radio5);
RB6 = (RadioButton) findViewById(R.id.radio6);
RB7 = (RadioButton) findViewById(R.id.radio7);
RB8 = (RadioButton) findViewById(R.id.radio8);
RB9 = (RadioButton) findViewById(R.id.radio9);
RB10 = (RadioButton) findViewById(R.id.radio10);
//names of my radio buttons
RBGroup = (RadioGroup) findViewById(R.id.RBGroup);
RBGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup RBGroup, int checkedId) {
team1.setText(checkedId);
}
});