1

我正在使用带有 C++ Builder 10.1 的 FireMonkey for Android。我必须使用 C++ Builder 从 C++ 调用 Java 方法。但我找不到解决办法。你有这个工作的例子吗?或者如何从 C++ Builder for Android 调用 Java 方法?

我正在尝试调用以下 Java 代码:

package com.javacodes;

import java.util.Calendar;

import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.widget.DatePicker;
import android.widget.TimePicker;
import android.widget.Toast;
import android.content.Context;

public class Picker
{
    private static Calendar calendar = Calendar.getInstance();
    private static String date, time;
    private static Context c;

    public Picker()
    {
    }

    public static String datePickerDialog(Context context)
    {
        c = context;
        DatePickerDialog datePickerDialog = new DatePickerDialog(c,
                new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
                        date = i2 + "/" + i1 + "/" + i;
                        Toast.makeText(c, date, Toast.LENGTH_LONG).show();
                    }
                }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
        datePickerDialog.show();

        return date;
    }

    public static String timePickerDialog(Context context)
    {
        c = context;
        TimePickerDialog timePickerDialog = new TimePickerDialog(c,
                new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker timePicker, int i, int i1) {
                        time = i + " : " + i1;
                        Toast.makeText(c, time, Toast.LENGTH_LONG).show();
                    }
                }, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false);
        timePickerDialog.show();

        return time;
    }
}
4

0 回答 0