##ListView読み込み
- 件数指定
- 自動・手動
- 追加ボタン・オーバースクロール
- リストアイテム非同期読み込みとか
##AsyncTask
- 結果のコールバック
| package net.nessness.android.sample.listview; | |
| import java.util.ArrayList; | |
| import java.util.HashMap; | |
| import android.app.ListActivity; | |
| import android.os.Bundle; | |
| import android.widget.ListView; | |
| import android.widget.SimpleAdapter; | |
| public class ListViewSampleActivity extends ListActivity { |
| <?xml version="1.0" encoding="utf-8"?> | |
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
| <item android:state_pressed="true"> | |
| <layer-list> | |
| <item android:drawable="@drawable/btn_back"/> | |
| <item android:drawable="@drawable/list_pressed_holo_light"/> | |
| </layer-list></item> | |
| <item android:drawable="@drawable/btn_back"></item> |
| text = client.execute(httpGet, new ResponseHandler<String>() { | |
| @Override | |
| public String handleResponse(HttpResponse resp) | |
| throws ClientProtocolException, IOException { | |
| if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { | |
| throw new IOException(resp.getStatusLine().getStatusCode() + "returned."); | |
| } | |
| HttpEntity entity = resp.getEntity(); | |
| if (entity != null) { | |
| InputStream is = entity.getContent(); |
| 527 /** | |
| 528 * Set the descendant focusability of this view group. This defines the relationship | |
| 529 * between this view group and its descendants when looking for a view to | |
| 530 * take focus in {@link #requestFocus(int, android.graphics.Rect)}. | |
| 531 * | |
| 532 * @param focusability one of {@link #FOCUS_BEFORE_DESCENDANTS}, {@link #FOCUS_AFTER_DESCENDANTS}, | |
| 533 * {@link #FOCUS_BLOCK_DESCENDANTS}. | |
| 534 */ | |
| 535 public void setDescendantFocusability(int focusability) { | |
| 536 switch (focusability) { |
| FragmentStatePagerで持ってるfragmentはめくっていくとonStopが呼ばれるのでここでよしなにするとよい(かも |
##ListView読み込み
##AsyncTask
| public static Twitter getTwitter(Context ctx) { | |
| InputStream is = null; | |
| TwitterFactory tf; | |
| try { | |
| is = ctx.getResources().getAssets().open("twitter4j.properties"); | |
| PropertyConfiguration conf = new PropertyConfiguration(is); | |
| tf = new TwitterFactory(conf); | |
| } catch (IOException e) { | |
| tf = new TwitterFactory(); |
| public static long copyFileStream(FileInputStream is, FileOutputStream os) | |
| throws IOException { | |
| FileChannel srcChannel = null; | |
| FileChannel destChannel = null; | |
| try { | |
| srcChannel = is.getChannel(); | |
| destChannel = os.getChannel(); | |
| return srcChannel.transferTo(0, srcChannel.size(), destChannel); | |
| } finally { |
| pulic static void logd(String format, Object... args) { | |
| Log.d(TAG, String.format(Locale.getDefault(), format, args)); | |
| } |