mirror of
https://github.com/etlegacy/etlegacy-android.git
synced 2024-11-10 06:52:06 +00:00
java: add Functional Buttons
In order not to over cluster screens, create Popup Menu with functional keys. F1 and F2 available for now.
This commit is contained in:
parent
2bd357d03e
commit
46b4fa32da
1 changed files with 33 additions and 0 deletions
|
@ -9,11 +9,13 @@ import android.graphics.Color;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.erz.joysticklibrary.JoyStick;
|
||||
|
@ -54,6 +56,37 @@ public class ETLActivity extends SDLActivity implements JoyStickListener {
|
|||
|
||||
if (getUiMenu() == true) {
|
||||
|
||||
final ImageButton buttonPopUpMenu = new ImageButton(getApplicationContext());
|
||||
buttonPopUpMenu.setImageBitmap(getBitmapFromAsset("btn_menu.png"));
|
||||
buttonPopUpMenu.setBackgroundResource(0);
|
||||
mLayout.addView(buttonPopUpMenu);
|
||||
buttonPopUpMenu.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PopupMenu etl_PopMenu = new PopupMenu(getApplicationContext(), buttonPopUpMenu);
|
||||
etl_PopMenu.getMenu().add(0, 0, 0, "F1");
|
||||
etl_PopMenu.getMenu().add(1, 1, 1, "F2");
|
||||
etl_PopMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case 0:
|
||||
SDLActivity.onNativeKeyDown(131);
|
||||
SDLActivity.onNativeKeyUp(131);
|
||||
break;
|
||||
case 1:
|
||||
SDLActivity.onNativeKeyDown(132);
|
||||
SDLActivity.onNativeKeyUp(132);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
etl_PopMenu.show();
|
||||
}
|
||||
});
|
||||
|
||||
ImageButton btn2 = new ImageButton(getApplicationContext());
|
||||
btn2.setId(2);
|
||||
btn2.setImageBitmap(getBitmapFromAsset("btn_sht.png"));
|
||||
|
|
Loading…
Reference in a new issue