I'm trying to add a button to one of the default emulator skins. I used the layout file to get the button to appear but I'm not sure how t开发者_StackOverflow社区o map it so that it actually does something.
You want to grab the button from the layout XML with something like this in onCreate:
Button xButton = (Button)findViewById(R.id.buttonX); //buttonX is the id you gave the button in the layout
Then you could set a click listener for that button in your onCreate like this:
xButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// do stuff here
}});
Very late but here is what I've found:
- Create your skin as normal with the button images in place (rendered)
- Create a button overlay image which is going to be drawn over the button when you mouse move over it with the mouse (can be the same for all buttons given it is only meant to be a focus indicator)
- In your skin define the button(s) in the layout (see below)
- For each button you can link it to a specific qemu code (see https://android.googlesource.com/platform/external/qemu.git/+/8b9887163ce94928aec159956d1a61fc93bb949d/android/skin/file.c#122)
layout:
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: I am pretty sure the button size is dependant on the button image dimensions.
精彩评论