这样
<ImageButton android:id="@+id/c0r0" android:layout_width="15dip" android:layout_height="15dip"></ImageButton>
<ImageButton android:id="@+id/c1r0" android:layout_width="15dip" android:layout_height="15dip" ></ImageButton>
<ImageButton android:id="@+id/c2r0" android:layout_width="15dip" android:layout_height="15dip" ></ImageButton>
<ImageButton android:id="@+id/c0r1" android:layout_width="15dip" android:layout_height="15dip"></ImageButton>
<ImageButton android:id="@+id/c1r1" android:layout_width="15dip" android:layout_height="15dip" ></ImageButton>
<ImageButton android:id="@+id/c2r1" android:layout_width="15dip" android:layout_height="15dip" ></ImageButton>

解决方案 »

  1.   

    这样获取好像是不行唉。 但是可以在循环里new 按钮,通过代码加入到布局中嘛。
      

  2.   

    这个要求好变~态啊
    循环外面创建一个放button的地方 随便你自己怎么实现
    ArrayList<Button> buttonlist = new ArrayList<Button>();循环里面
    String name = "c"+i+"r"+j;
    int id;
    try {
    Field a = R.id.class.getField(name);
    id = a.getInt(a); } catch (Exception e) {
    e.printStackTrace();
    }
    buttonlist.add((Button)findViewById(id));
    拿去试试
      

  3.   

    看来是思路有问题我本来的想法是,在界面上有10行*10列的按钮,定义在了xml布局文件中,想通过java程序在获取这些按钮,然后给每个按钮注册同一个监听器。
      

  4.   

    ((ImageButton)findViewById(id)).setListener...不就可以了?