[fpc-pascal] ppcjvm issues

leledumbo leledumbo_cool at yahoo.co.id
Sat Jan 7 19:39:21 CET 2017


> The first issue I ran into is this: 
> 
> procedure Cppp1Activity.onResume; 
> begin 
>      inherited onResume; 
>      with AAAlertDialog.InnerBuilder(self) do begin 
>          setTitle(R.strings.app_name); 
>      end; 
> end;

I don't check by running the code directly, but looking at the source code:

  AAAlertDialog = class external 'android.app' name 'AlertDialog' (AADialog,
ACDialogInterface)
  public
    type
      InnerBuilder = class;
      Arr1InnerBuilder = array of InnerBuilder;
      Arr2InnerBuilder = array of Arr1InnerBuilder;
      Arr3InnerBuilder = array of Arr2InnerBuilder;
      InnerBuilder = class external 'android.app' name 'Builder' (JLObject)

InnerBuilder doesn't look like anything callable.

Reading the offical reference
(https://developer.android.com/guide/topics/ui/dialogs.html#AlertDialog), I
guess you need to instantiate it first and only then call its methods:

var
  Builder: AAAlertDialog.InnerBuilder;
  Dialog: AAAlertDialog;
...
  Builder := AAAlertDialog.InnerBuilder.Create(Self); // inside any
Cppp1Activity method so Self refers to Cppp1Activity instance
  Dialog := Builder.setTitle(R.strings.app_name).create_; // note the '_'

> When attempting to compile this it tells me that "float" is undefined. I 
> think I'm missing something here. "float" is the native Java name for
> their 
> base floating point type and its a valid type for FPC. If I use "single" 
> instead it will compile. Seems odd. 

Pascal's Single maps to Java's float. There's another float type defined in
Math unit but that's created for the routines inside the unit. Java's
primitive type is not available in FPC JVM, use Pascal's type after mapping
from Java. The class version (which should automatically (un)box) is
available, though. So if you insist, simply use JLFloat.



--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/ppcjvm-issues-tp5727228p5727238.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list