Tuesday, October 2, 2012

Android - How to detect end of scroll inside List View

Step 1: Set the scroll listener of the list view like below.


list.setOnScrollListener(new OnScrollListener() {});

Step 2: Override the onScroll function and copy/paste the following code

@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {

if (list.getLastVisiblePosition() == list.getAdapter().getCount() - 1
&& list.getChildAt(list.getChildCount() - 1).getBottom() <= list.getHeight()) {
//scroll end reached
//Write your code here
}
}



Sunday, July 29, 2012

How to build android project with Ant ?


Replace () with your own value

Step 1:  cd to project directory

Step 2: android update project -p .

Step 3: linux/unix: nano ant.properties  
            windows: notepad ant.properties

Step 4: input the following: 


  key.store=(path of key store file )/.keystore
  key.alias=(name of alias)
  key.store.password=(password of key store)
  key.alias.password=(password of key alias)

Step 5: 
ant release;
adb install -r bin/(generated file name).apk;
adb shell am start -a android.intent.action.MAIN -n (package name)/(package name).(activity name)

To make life easier, put step 5 inside a bash script and run it :)



Ant でAndroidプロジェクトをビルド方法:(in Japanese)
ーーーーーーーーーーーーーーーーーーー

Step 1: コマンドプロンプトで プロジェクトフォルダの中に移動する (cd コマンド)

Step 2: android update project -p .

Step 3: notepad ant.properties

Step 4:  下記を記載して保存
  key.store=??/.keystore
  key.alias=??
  key.store.password=??
  key.alias.password=??

Step 5: ant release;adb install -r bin/.apk;adb shell am start -a android.intent.action.MAIN -n package name/package name.activity name

Tuesday, July 3, 2012

Android - Change the default focus inside a Alert dialogue

set on focus change for any object inside the dialog.

@Override
public void onFocusChange(View view, boolean hasFocus) {
// Set focus where ever you want according to your custom logic

// for example to focus on the positive button after a webview scroll
// web is the webview and the buttons are initialized inside onCreateDialog 

        if(!web.isFocused() && !positiveButton.isFocused() && negativeButton.isFocused()){
            positiveButton.requestFocus();
        }

}


Android - How to detect scroll inside webview?

Create a custom webview class which extends of course webview :)


public class CustomWebView extends WebView 

Override the following method

@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) 

int l is x, int is y

Thats it :)

Android - Can not focus into objects inside listview?

listView.setItemsCanFocus(true);//self explanatory

 Edit the view that you want to add inside the listview. Add the following property.
 android:descendantFocusability="afterDescendants"

 The End :)

Tuesday, August 23, 2011

Monday, May 23, 2011

あなたの目

あなたの目は何かを語っている。
あなたは笑顔の裏に傷みを抱えている。
一つサインをわかっても、他のサインを見逃している?

何があなたの心を悩ませているか?教えて。。。