我想做一个简单的游戏.. 我有一个计时器,每一秒我都会向main.xml添加一个新按钮 按钮总是向下移动 如果我点击特定按钮,它将被删除
请帮帮我..我必须做什么?使用数组按钮?帮助..我只是一个新手 我知道你可以在几分钟内解决这个问题.. =(离
b[indek] = new Button(context)
layout = (LinearLayout) View.inflate(this, R.layout.main, null);
b[indek].setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
indek++;
答案 0 :(得分:1)
获取布局实例
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
In your xml file, main xml layout android:id="@+id/layout"
并向此布局添加新按钮使用layout.addView( b[indek] )
看看this示例