小编Mac*_*tch的帖子

Android中的按钮数组

我想将按钮映射到一个按钮数组,并且代码在编译时没有错误但是当我运行它时有强制关闭:

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)

arrays android android-button

10
推荐指数
2
解决办法
4万
查看次数

使用前景标签将图像添加到Jbutton

朋友们,我尝试使用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方法中的简单框架.

java swing background image jbutton

2
推荐指数
1
解决办法
2万
查看次数

我们可以直接将音频文件发送到电话运营商的上行链路吗?

我是android开发的初学者,感觉像谷歌文档无法帮助我.那么,如果有人知道是否有可能在呼叫之间直接向上行链路发送音频文件?还分享如何做到这一点.

audio android voice call carrier

0
推荐指数
1
解决办法
1600
查看次数

标签 统计

android ×2

android-button ×1

arrays ×1

audio ×1

background ×1

call ×1

carrier ×1

image ×1

java ×1

jbutton ×1

swing ×1

voice ×1