程序没有问题,但是Toast却没有显示,这是怎么回事啊?
解决方案 »
- android获取html后,点击图片显示大图问题
- android 获取U盘路径
- 如何知道系统当前弹出键盘中的输入法?或者看我的需求
- Runs Android List问题,无法启动模拟运行
- android中如何屏蔽屏幕翻转
- 怎么停止logcat继续往文件里记录?
- 关于安卓画布
- 点击事件返回值true||false
- 【菜鸟Android开发】Android开发Log.v() 报错Syntax error on token ")", delete this token
- 1024x600分辨率的机器安装“全民K歌TV版”部分控件显示异常
- 显示对话框时背景会出现一条没遮住的地方...怎么回事?
- 为什么我到android源码编译出来,没有system,img。。只有data和ramdisk.img
package my.widget.radiabutton;import android.app.Activity;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.Toast;public class RadiaButtonProjectActivity extends Activity implements OnCheckedChangeListener{
/** Called when the activity is first created. */
private RadioButton rb1,rb2,rb3,rb4;
private RadioGroup rg;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
rb1=(RadioButton)findViewById(R.id.rb1);
rb2=(RadioButton)findViewById(R.id.rb2);
rb3=(RadioButton)findViewById(R.id.rb3);
rb4=(RadioButton)findViewById(R.id.rb4);
rg=(RadioGroup)findViewById(R.id.radGrp);
rg.setOnCheckedChangeListener(this);
}
public void onCheckedChange(RadioGroup group,int checkedId){
String rbName=null;
if(checkedId==rb1.getId()){
rbName=rb1.getText().toString();
}
else if(checkedId==rb2.getId()){
rbName=rb2.getText().toString();
}
else if(checkedId==rb3.getId()){
rbName=rb3.getText().toString();
}
else if(checkedId==rb4.getId()){
rbName=rb4.getText().toString();
}
Toast.makeText(this,rbName, Toast.LENGTH_LONG).show();
}
public void onCheckedChanged(RadioGroup group, int checkedId)
{
// TODO Auto-generated method stub
}
}就是监听四个radiobutton用toast显示信息而已,怎么就是没有显示呢/?
如果执行了还不出来那试试用handler延时弹出toast
改成Toast.makeText(RadiaButtonProjectActivity.this,rbName, Toast.LENGTH_LONG).show();