2013年9月20日金曜日

Android開発における便利な機能

importの自動補完
「Command+Shift+o」

AndroidにおけるAzureの使用、SQLにinsert

AndroidからAzureのSQLを使用には、簡単です。

1)Tableの構造と合うclassを用意します。

package com.example.azuretest;

public class TokutenItem {
@com.google.gson.annotations.SerializedName("id")
private int mId;
@com.google.gson.annotations.SerializedName("venusId")
private String mVenusId;

@com.google.gson.annotations.SerializedName("pointUp")
private  float mPointUp;
@com.google.gson.annotations.SerializedName("pricedown")
private int mPriceDown;
@com.google.gson.annotations.SerializedName("cardId")
private int mCardId;
public TokutenItem(String venusId, float pointUp, int priceDown, int cardId) {
//this.setId(id); idは自動的に付与され、set不可のようです
this.setVenusId(venusId);
this.setPointUp(pointUp);
this.setPriceDown(priceDown);
this.setCardId(cardId);
}
public int getId() {
return mId;
}
public String getVenusId() {
return mVenusId;
}
public float getPointUp() {
return mPointUp;
}
public int getPriceDown() {
return mPriceDown;
}
public int getCardId() {
return mCardId;
}
public final void setId(int id) {
mId = id;
}
public final void setVenusId(String venusId) {
mVenusId = venusId;
}
public final void setPointUp(float pointUp) {
mPointUp = pointUp;
}
public final void setPriceDown(int priceDown) {
mPriceDown = priceDown;
}
public final void setCardId(int cardId) {
mCardId = cardId;
}
}

2)MobileServiveClientの設定、そしてMobileServiceTableの設定

try {
// Create the Mobile Service Client instance, using the provided
// Mobile Service URL and key
mClient = new MobileServiceClient(
"https://xxxxxxx.azure-mobile.net/",
"keyforAzuraMobileService"
this);

// Get the Mobile Service Table instance to use
mTokutenTable = mClient.getTable(TokutenItem.class);
     } catch (MalformedURLException e) {
createAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
       }
        // 挿入したいItem項目をclassに入れる、idの設定は不可
TokutenItem mTokutenItem = new TokutenItem("4e25173e091a817e3dd67300",2,300,3);
mTokutenTable.insert(mTokutenItem, new TableOperationCallback<TokutenItem>() {
        public void onCompleted(TokutenItem entity, 
                Exception exception, 
                ServiceFilterResponse response) {   
           if (exception == null) {
        //Log.i(TAG, "Read object with ID " + entity.id);
           } else {
        createAndShowDialog(exception, "Error");
           }
        }
});

getTableは、classの構造に合わせて、SQLの列を追加してくれます。

3) Permissionの追加を忘れず
<uses-permission android:name="android.permission.INTERNET" />

2013年9月18日水曜日

AdapterのgetView()

ListViewに内容を表示させるには、AdapterはデータとListViewの中間役になります。Adapterの役割の中心は、getView()です。ListViewは新しいrowを表示する際、その都度getView()を呼び出します。

public abstract View getView (int positionView convertView, ViewGroup parent)

Added in API level 1
Get a View that displays the data at the specified position in the data set. You can either create a View manually or inflate it from an XML layout file. When the View is inflated, the parent View (GridView, ListView...) will apply default layout parameters unless you use inflate(int, android.view.ViewGroup, boolean) to specify a root view and to prevent attachment to the root.
Parameters
positionThe position of the item within the adapter's data set of the item whose view we want.
convertViewThe old view to reuse, if possible. Note: You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view. Heterogeneous lists can specify their number of view types, so that this View is always of the right type (see getViewTypeCount() and getItemViewType(int)).
parentThe parent that this view will eventually be attached to
Returns
  • A View corresponding to the data at the specified position.

2013年9月13日金曜日

Azureプレミアクーポン券をいただいた

日本MS本社に、あるセミナーに参加しに行ったら、何と454,500円分のAzureプレミアクーポンをいただきました。これはありがたいです。ますます、Azureに傾くようになりました。MSさんはクラウド分野で、一生懸命追いついていますね。

2013年9月6日金曜日

mac使用

開発機は、2013年型のMAC Airにしました。
同じスペックのWindowsよりは安いし、UNIXコマンドが使えるし、iosの開発もできるため、迷いなくMBAにしました。

よく利用方法は、ここで追加していきます。

【強制終了】
「command + option + esc」

スクリーンショット】
1.画面全体「command」+ 「Shift」+ 「3」 
  
2.
ドラッグで選択した部分command」 + 「Shift」+ 「4」
  
3.まず「
command」+ 「Shift」 + 「4」、そして + 「Space」
  カメラアイコンが表示される。カメラアイコンで選択した一つのウインドウ


【ルートユーザーを有効化】
http://support.apple.com/kb/ht1528?viewlocale=ja_JP

AWSのセミナーに参加しました

AWSのサービスメニューが多すぎ、わけが分からなくなります。公開セミナーに参加しました。セミナーの内容を聞いても、サービスの全体図はよくわかりません。
サーバー構築・管理の基礎知識のない私にとって、AWSのハードルが高いです。

分かりやすいWindows Azureを使って、頑張っていきます。

2013年9月1日日曜日

MACにSVN (Subversion)をインストール

あるサイトのソースコードを確認するには、SVNコマンドが必要と言われました。MACのコマンドラインでwhich svnを叩いても何もでてきません。

ネットで調べたところ、下記のリンクを見つかりました。

http://ja.katzueno.com/2012/08/2991/

要は、Xcodeを入れた後、command line toolsをインストールということです。