向android仿真器皮肤添加按钮
我正在尝试向其中一个默认仿真器外观添加一个按钮。我使用布局文件来显示按钮,但我不确定如何映射它,以便它实际执行某些操作。您想在onCreate中使用类似以下内容从布局XML中获取按钮:向android仿真器皮肤添加按钮,android,android-emulator,android-layout,Android,Android Emulator,Android Layout,我正在尝试向其中一个默认仿真器外观添加一个按钮。我使用布局文件来显示按钮,但我不确定如何映射它,以便它实际执行某些操作。您想在onCreate中使用类似以下内容从布局XML中获取按钮: Button xButton = (Button)findViewById(R.id.buttonX); //buttonX is the id you gave the button in the layout 然后,您可以在onCreate中为该按钮设置一个单击侦听器,如下所示: xButton.setOn
Button xButton = (Button)findViewById(R.id.buttonX); //buttonX is the id you gave the button in the layout
然后,您可以在onCreate中为该按钮设置一个单击侦听器,如下所示:
xButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// do stuff here
}});
很晚了,但我发现: 使用就地渲染的按钮图像创建正常的蒙皮 创建一个按钮覆盖图像,当你用鼠标在按钮上移动时,它将被绘制在按钮上,如果它只是一个焦点指示器,那么所有按钮的覆盖图像可以是相同的 在皮肤中定义布局中的按钮,请参见下文 对于每个按钮,您可以将其链接到特定的qemu代码,请参阅 布局:
parts {
device {
...
}
portrait {
...
buttons {
search { // see qemu codes
image xxxx.png // the overlay image to show on mouse move over
x 00000 // the top-left coordinate to show the image
y 00000 //
}
}
}
}
PS:我非常确定按钮大小取决于按钮图像尺寸。是否要为按钮指定一个点击处理程序?是的,但要为皮肤上的按钮指定一个点击处理程序。我想在源代码中更改实际的模拟器。为什么这是公认的答案?问题是模拟器皮肤上的一个按钮,而不是布局xml。好问题,我试着回想9年前,但我的答案不是针对模拟器的,所以它似乎不完全适合这个问题。