mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-12 09:39:16 +02:00
Initial work for Android menu support
git-svn-id: trunk@36392 -
This commit is contained in:
parent
6edfeb2724
commit
348a233427
@ -9,6 +9,7 @@ import android.graphics.*;
|
||||
import android.text.*;
|
||||
import android.view.*;
|
||||
import android.view.inputmethod.*;
|
||||
import android.view.MenuItem.*;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.Intent;
|
||||
import android.hardware.Sensor;
|
||||
@ -247,6 +248,40 @@ public class LCLActivity extends Activity implements SensorEventListener, Locati
|
||||
//Log.i("lclapp", "onConfigurationChanged finished");
|
||||
}
|
||||
|
||||
@Override public boolean onPrepareOptionsMenu (Menu menu)
|
||||
{
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
|
||||
int i;
|
||||
|
||||
// First clear the captions list
|
||||
for (i = 0; i<6; i++)
|
||||
lclmenu_captions[i] = "";
|
||||
|
||||
// Now ask the LCL to fill it
|
||||
LCLOnMenuAction(0, 0);
|
||||
|
||||
// And fill the menus with it
|
||||
menu.clear();
|
||||
for (i = 0; i<6; i++)
|
||||
{
|
||||
if (lclmenu_captions[i] != "")
|
||||
{
|
||||
MenuItem lMenuItem = menu.add(0, i, 0, lclmenu_captions[i]);
|
||||
lMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener()
|
||||
{
|
||||
public boolean onMenuItemClick(MenuItem item)
|
||||
{
|
||||
LCLOnMenuAction(1, item.getItemId());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------
|
||||
// JNI table of Pascal functions
|
||||
// -------------------------------------------
|
||||
@ -258,6 +293,7 @@ public class LCLActivity extends Activity implements SensorEventListener, Locati
|
||||
public native int LCLOnTimer(Runnable timerid);
|
||||
public native int LCLOnConfigurationChanged(int ANewDPI, int ANewWidth);
|
||||
public native int LCLOnSensorChanged(int ASensorKind, double[] AValues);
|
||||
public native int LCLOnMenuAction(int kind, int itemIndex);
|
||||
|
||||
// -------------------------------------------
|
||||
// Functions exported to the Pascal side
|
||||
@ -628,6 +664,8 @@ public class LCLActivity extends Activity implements SensorEventListener, Locati
|
||||
// for LazDeviceAPIs
|
||||
public String lcldestination;
|
||||
public int lclkind;
|
||||
// for the menus
|
||||
public String[] lclmenu_captions = new String[6];
|
||||
|
||||
static
|
||||
{
|
||||
|
@ -72,7 +72,7 @@
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<Libraries Value="C:/Programas/android-ndk-r7/platforms/android-8/arch-arm/usr/lib"/>
|
||||
<Libraries Value="C:/Programas/android-ndk-r7b/platforms/android-8/arch-arm/usr/lib"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
|
@ -17,6 +17,7 @@ exports
|
||||
Java_com_pascal_lclproject_LCLActivity_LCLOnTimer name 'Java_com_pascal_lcltest_LCLActivity_LCLOnTimer',
|
||||
Java_com_pascal_lclproject_LCLActivity_LCLOnConfigurationChanged name 'Java_com_pascal_lcltest_LCLActivity_LCLOnConfigurationChanged',
|
||||
Java_com_pascal_lclproject_LCLActivity_LCLOnSensorChanged name 'Java_com_pascal_lcltest_LCLActivity_LCLOnSensorChanged',
|
||||
Java_com_pascal_lclproject_LCLActivity_LCLOnMenuAction name 'Java_com_pascal_lcltest_LCLActivity_LCLOnMenuAction',
|
||||
JNI_OnLoad name 'JNI_OnLoad',
|
||||
JNI_OnUnload name 'JNI_OnUnload';
|
||||
|
||||
|
@ -88,7 +88,7 @@ object Form1: TForm1
|
||||
end
|
||||
object ComboBox1: TComboBox
|
||||
Left = 72
|
||||
Height = 27
|
||||
Height = 21
|
||||
Top = 128
|
||||
Width = 140
|
||||
AutoSize = False
|
||||
|
@ -7,7 +7,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
LCLProc, Arrow, StdCtrls, ComCtrls, LCLType, LCLIntf, InterfaceBase,
|
||||
lazdeviceapis;
|
||||
lazdeviceapis, Menus;
|
||||
|
||||
type
|
||||
TSubControl = class;
|
||||
|
Loading…
Reference in New Issue
Block a user