屏幕上输出我喜欢java的代码_编程就是和喜欢的人表白

Caiquan.java     //Next.java 在这里就不一一列举了,不然就是一堆代码

import android.*;   //都是自动导的包,在这里我就省略了。

public class Caiquan extends Activity {

private RadioGroup radioGroup1,radioGroup;

private RadioButton shitouButton1,buButton1,jiandaoButton1;

private RadioButton jiandaoButton,buButton,shitouButton;

private Button button1,button2;

private TextView textview1,textview;

private ImageView imageview;

private ImageView imageview1;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_caiquan);

textview1=(TextView)findViewById(R.id.textView1);

textview=(TextView)findViewById(R.id.game);

button1 = (Button) findViewById(R.id.button1);

button2 = (Button) findViewById(R.id.button2);

button1.setOnClickListener(new ButtonListener());

button2.setOnClickListener(new ButtonListener());

radioGroup=(RadioGroup)findViewById(R.id.radioGroupId);

radioGroup1=(RadioGroup)findViewById(R.id.radioGroupId1);

shitouButton1=(RadioButton)findViewById(R.id.radioButton1);

buButton1=(RadioButton)findViewById(R.id.radioButton3);

jiandaoButton1=(RadioButton)findViewById(R.id.radioButton5);

jiandaoButton=(RadioButton)findViewById(R.id.radioButton2);

shitouButton=(RadioButton)findViewById(R.id.radioButton4);

buButton=(RadioButton)findViewById(R.id.radioButton6);

RadioButtonListener Radiolistener = new RadioButtonListener();

shitouButton1.setOnCheckedChangeListener(Radiolistener);

buButton1.setOnCheckedChangeListener(Radiolistener);

jiandaoButton1.setOnCheckedChangeListener(Radiolistener);

jiandaoButton.setOnCheckedChangeListener(Radiolistener);

shitouButton.setOnCheckedChangeListener(Radiolistener);

buButton.setOnCheckedChangeListener(Radiolistener);

imageview1 = (ImageView) findViewById(R.id.imageView1);

imageview = (ImageView) findViewById(R.id.imageView2);

}  //在这里也可以为findViewById 方法和绑定监听器 设置两个方法

class ButtonListener implements OnClickListener{

private String win;

@Override

public void onClick(View v) {

RadioButton radioButtonleft = (RadioButton) findViewById(radioGroup1

.getCheckedRadioButtonId());

String radioTextleft = radioButtonleft.getText().toString();

RadioButton radioButtonright = (RadioButton) findViewById(radioGroup

.getCheckedRadioButtonId());

String radioTextright = radioButtonright.getText().toString();

Intent intent= new Intent();

intent.setClass(Caiquan.this, Next.class);

intent.putExtra("checked", radioTextleft);

intent.putExtra("checked", radioTextright);

intent.putExtra("com.Jackson.game_intent.jieguo", win);

startActivity(intent);   }

}// 用radioText记录被选中的单选按钮的值,传达到下一个  Activity

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.caiquany, menu);

return true;

}

public boolean onOptionsItemSelected(MenuItem item) {

// Handle action bar item clicks here. The action bar will

// automatically handle clicks on the Home/Up button, so long

// as you specify a parent activity in AndroidManifest.xml.

int id = item.getItemId();

if (id == R.id.action_settings) {

return true;

}

return false;

}}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值