2016-03-23 4 views
-1

私は現在のアンドロイドアプリケーションと接続している晴れのアカウントを作成し、テーブルを作成し、アプリケーション内からこのテーブルにデータを追加しました。テキストがテキストボックスに追加され、ボタンがクリックされてデータがAzureに送信されます。リスト内の "Text"フィールドでこのデータを取得できるようにします。誰も私がこれをやる方法を私に見せてもらえますか? POJOクラスItem.javaをファイルのAzureからデータを取得する

MainActivity

public class MainActivity extends AppCompatActivity { 
    private MobileServiceClient mClient; 
    private EditText title; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     try { 
      mClient = new MobileServiceClient(
        "https://craigsapp.azure-mobile.net/", 
        "BTkcgnFQvevAdmmRteHCmhHPzdGydq84", 
        this 
      ); 
     } catch (MalformedURLException e) { 
      e.printStackTrace(); 
     } 

    } 

    public void onClickB(View view) { 

title= (EditText) findViewById(R.id.editText); 

     Item item = new Item(); 
     item.Text = title.getText().toString(); 

     mClient.getTable(Item.class).insert(item, new TableOperationCallback<Item>() { 
      public void onCompleted(Item entity, Exception exception, ServiceFilterResponse response) { 
       if (exception == null) { 
        // Insert succeeded 
       } else { 
        // Insert failed 
       } 
      } 
     }); 
    } 

} 

項目アクティビティ

public class Item { 
    public String Id; 
    public String Text; 

} 

答えて

0

を休閑として

私のコードです。

public class Item { 
    @com.google.gson.annotations.SerializedName("id") 
    private String id; 

    @com.google.gson.annotations.SerializedName("text") 
    private String text; 

    public Item() {} 
    public Item(String id, String text) { 
     this.id = id; 
     this.text = text 
    } 

    // The getter and setter functions for echo property, and the functions `toString` and `equals` 
    ...... 
} 

を基準として、似サンプルプロジェクトGetStartedWithDataあり、https://github.com/Azure/mobile-services-samples/tree/master/GettingStartedWithData/Android/GetStartedWithData/src/com/example/GetStartedWithDataを参照してください。

モバイルサービスにデータを挿入する場合は、How to: Insert data into a mobile serviceのセクションを参照してください。

0

azureデータベースからデータを取得するには、asynctaskまたはAndroidサービスを使用してデータを取得し、ブロードキャスト受信機を使用してテキストフィールドに取得する必要があります。 下記のコメントを依頼する必要がある場合は、

関連する問題