<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/lblText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> </LinearLayout>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.thaicreate" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
package com.example.thaicreate; import java.net.MalformedURLException; import android.app.Activity; import android.os.Bundle; import android.view.Menu; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }
package com.example.thaicreate; import java.net.MalformedURLException; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.widget.TextView; import com.microsoft.windowsazure.mobileservices.MobileServiceClient; public class MainActivity extends Activity { private MobileServiceClient mClient; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try { mClient = new MobileServiceClient( "https://thaicreate.azure-mobile.net/", "QUjngFknhHZjdaGgYAAzdoXkOzKoxi24", this ); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } final TextView lbText = (TextView) findViewById(R.id.lblText); if (mClient == null) { lbText.setText("Android Connect Failed"); } else { lbText.setText("Android Connected to Mobile Servie"); } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท