サンプルコード例

サンプルコード例

お知らせ:当社は、お客様により充実したサポート情報を迅速に提供するため、本ページのコンテンツは機械翻訳を用いて日本語に翻訳しています。正確かつ最新のサポート情報をご覧いただくには、本内容の英語版を参照してください。

メモ: Zoho Creator のモバイル SDK は現在ベータ版機能です。本番環境のアプリでは使用しないことをおすすめします。

Java

以下は、Android 向け Zoho Creator SDK の各種メソッドの使用方法を示すコードスニペットです:

Creator アプリ内に存在するセクションを取得する

次のスニペットでは、Zylker_Orders が対象の Creator アプリケーションのリンク名です:
  1. try {
  2. // ここにコードを記述します

  3. ZCApplication firstApp = appList。取得する(0);
  4. List<ZCSection> sections =
  5. ZOHOCreatorUtil。getApplicationDetails(firstApp);
  6. } catch (ZCException e) {
  7. e。printStackTrace();
  8. // エラー処理を行う
  9. }

フォームのメタ情報を取得する

次のスニペットでは、注文 が対象フォームのリンク名です:
  1. try {
  2. ... // ここにコードを記述します
  3. ZCSection firstSection = sections。取得する(0);
  4. ZCComponent firstComponent =
  5. firstSection。getComponents().取得する(0);
  6. if(firstComponent。getType().equals(ZCComponentType。FORM)){
  7. ZCForm form = FormUtil。getForm(firstComponent);
  8. }
  9. } catch (ZCException e) {
  10. e。printStackTrace();
  11. // エラー処理を行う
  12. }

レポートのメタ情報を取得する

次のスニペットでは、All_Orders が対象レポートのレポート名です:
  1. try {
  2. ... // ここにコードを記述します
  3. ZCSection firstSection = sections。取得する(0);
  4. ZCComponent firstComponent =
  5. firstSection。getComponents().取得する(0);
  6. if(firstComponent。getType().equals(ZCComponentType。レポート)){
  7. ZCReport レポート = ReportUtil。getReport(firstComponent);
  8. }
  9. } catch (ZCException e) {
  10. e。printStackTrace();
  11. // エラー処理を行う
  12. } catch (CloneNotSupportedException e) {
  13. e。printStackTrace();
  14. }

Kotlin

Creator アプリ内に存在するセクションを取得する

次のスニペットでは、Zylker_Orders が対象の Creator アプリケーションのリンク名です:
  1. try {
  2. ... // ここにコードを記述します
  3. val firstApp: ZCApplication = appList。取得する(0)
  4. val sections: List = ZOHOCreatorUtil。getApplicationDetails(firstApp)
  5. } catch (e: ZCException) {
  6. e。printStackTrace()
  7. // エラー処理を行う
  8. }

フォームのメタ情報を取得する

次のスニペットでは、注文 が対象フォームのリンク名です:
  1. try {
  2. ... // ここにコードを記述します
  3. val firstSection: ZCSection = sections。取得する(0)
  4. val firstComponent = firstSection.components。取得する(0)
  5. if (firstComponent。種類 == ZCComponentType。FORM) {
  6. val form: ZCForm = FormUtil。getForm(firstComponent)
  7. }
  8. } catch (e: ZCException) {
  9. e。printStackTrace()
  10. // エラー処理を行う
  11. }

レポートのメタ情報を取得する

次のスニペットでは、All_Orders が対象レポートのレポート名です:
  1. try {
  2. ... // ここにコードを記述します
  3. val firstSection: ZCSection = sections。取得する(0)
  4. val firstComponent = firstSection.components[0]
  5. if (firstComponent。種類 == ZCComponentType。レポート) {
  6. val レポート = ReportUtil。getReport(firstComponent, 50)
  7. }
  8. } catch (e: ZCException) {
  9. e。printStackTrace()
  10. // エラー処理を行う
  11. } catch (e: CloneNotSupportedException) {
  12. e。printStackTrace()
  13. }