android将;插入完整语句中
packagecom.example.radio;importandroid.app.Activity;importandroid.os.Bundle;importand...
package com.example.radio;
import android.app.Activity;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
public class Main extends Activity {
//对控件进行声明
private RadioGroup radiogroup = null;
private RadioButton first = null;
private RadioButton second = null;
private RadioButton third = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//通过控件的id得到控件对象
radiogroup = (RadioGroup)findViewById(R.id.radiogruop);
first = (RadioButton)findViewById(R.id.firstbutton);
third = (RadioButton)findViewById(R.id.thirdbutton);
//设置监听
radiogroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int chickId) {
// TODO Auto-generated method stub
if(first.getId()==chickId)
Toast.makeText(Main.this, "第一个radiobutton", Toast.LENGTH_SHORT).show();
else if(second.getId()==chickId)
Toast.makeText(Main.this, "第二个radiobutton", Toast.LENGTH_SHORT).show();
else if(third.getId()==chickId)
Toast.makeText(Main.this, "第三个radiobutton", Toast.LENGTH_SHORT).show();
}
});
}
}
描述 资源 路径 位置 类型
语法错误,将“;”插入到完整 语句 中 Main.java /radio/src/com/example/radio 第 39 行 Android Lint Problem 展开
import android.app.Activity;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
public class Main extends Activity {
//对控件进行声明
private RadioGroup radiogroup = null;
private RadioButton first = null;
private RadioButton second = null;
private RadioButton third = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//通过控件的id得到控件对象
radiogroup = (RadioGroup)findViewById(R.id.radiogruop);
first = (RadioButton)findViewById(R.id.firstbutton);
third = (RadioButton)findViewById(R.id.thirdbutton);
//设置监听
radiogroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int chickId) {
// TODO Auto-generated method stub
if(first.getId()==chickId)
Toast.makeText(Main.this, "第一个radiobutton", Toast.LENGTH_SHORT).show();
else if(second.getId()==chickId)
Toast.makeText(Main.this, "第二个radiobutton", Toast.LENGTH_SHORT).show();
else if(third.getId()==chickId)
Toast.makeText(Main.this, "第三个radiobutton", Toast.LENGTH_SHORT).show();
}
});
}
}
描述 资源 路径 位置 类型
语法错误,将“;”插入到完整 语句 中 Main.java /radio/src/com/example/radio 第 39 行 Android Lint Problem 展开
4个回答
展开全部
if(first.getId()==chickId){
Toast.makeText(Main.this, "第一个radiobutton", Toast.LENGTH_SHORT).show();
} else if(second.getId()==chickId){
Toast.makeText(Main.this, "第二个radiobutton", Toast.LENGTH_SHORT).show();
}else if(third.getId()==chickId){
Toast.makeText(Main.this, "第三个radiobutton", Toast.LENGTH_SHORT).show();
}
Toast.makeText(Main.this, "第一个radiobutton", Toast.LENGTH_SHORT).show();
} else if(second.getId()==chickId){
Toast.makeText(Main.this, "第二个radiobutton", Toast.LENGTH_SHORT).show();
}else if(third.getId()==chickId){
Toast.makeText(Main.this, "第三个radiobutton", Toast.LENGTH_SHORT).show();
}
展开全部
少了一个else,把最后一个else if改成else
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
设置监听 下面的那行代码 缺少 ; 其实报的错已经说的很清楚了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
if(first.getId()==chickId)
Toast.makeText(Main.this, "第一个radiobutton", Toast.LENGTH_SHORT).show();
else if(second.getId()==chickId)
Toast.makeText(Main.this, "第二个radiobutton", Toast.LENGTH_SHORT).show();
else
Toast.makeText(Main.this, "第三个radiobutton", Toast.LENGTH_SHORT).show();
}
Toast.makeText(Main.this, "第一个radiobutton", Toast.LENGTH_SHORT).show();
else if(second.getId()==chickId)
Toast.makeText(Main.this, "第二个radiobutton", Toast.LENGTH_SHORT).show();
else
Toast.makeText(Main.this, "第三个radiobutton", Toast.LENGTH_SHORT).show();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询