我想将按钮映射到一个按钮数组,并且代码在编译时没有错误但是当我运行它时有强制关闭:
Button buttons[];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game_board_view);
// Set OnClick listeners
Button buttons[] = null;
buttons[0] = (Button)findViewById(R.id.buttonOne);
buttons[1] = (Button)findViewById(R.id.buttonTwo);
buttons[2] = (Button)findViewById(R.id.buttonThree);
buttons[3] = (Button)findViewById(R.id.buttonFour);
buttons[4] = (Button)findViewById(R.id.buttonFive);
buttons[5] = (Button)findViewById(R.id.buttonSix);
buttons[6] = (Button)findViewById(R.id.buttonSeven);
buttons[7] = (Button)findViewById(R.id.buttonEight);
buttons[8] = (Button)findViewById(R.id.buttonMid);
}
Run Code Online (Sandbox Code Playgroud)
logcat的:
03-26 21:42:51.455: D/dalvikvm(1156): GC_EXTERNAL_ALLOC freed 55K, 53% free 2566K/5379K, external 1625K/2137K, paused 98ms
03-26 21:42:54.323: D/AndroidRuntime(1156): Shutting down VM
03-26 21:42:54.323: W/dalvikvm(1156): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-26 21:42:54.343: E/AndroidRuntime(1156): …Run Code Online (Sandbox Code Playgroud) 朋友们,我尝试使用seticon方法将图像添加到我的Jbutton,但它隐藏了按钮上的文本标签.这是代码:
try {
Image img = ImageIO.read(getClass().getResource("image.jpg"));
studentsButton.setIcon(new ImageIcon(img));
} catch (IOException ex) {
}
Run Code Online (Sandbox Code Playgroud)
我在没有init()/ paint()/ graphics的eclipse中使用swing,它在main方法中的简单框架.
我是android开发的初学者,感觉像谷歌文档无法帮助我.那么,如果有人知道是否有可能在呼叫之间直接向上行链路发送音频文件?还分享如何做到这一点.