編輯:關於android開發
實例核心代碼:
package com.stay.main;
import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.stay.wifi.R;
/**
* @author Stay
* 動態加載listview數據,上拉 刷新,下拉 更多
*/
public class ListViewActivity extends Activity implements OnScrollListener {
private static final int LOAD = 0;
private static final int ERROR = 0;
private static final int MEMBER = 1;
private static final int LOADED = 2;
private static final int DIALOG = 3;
private static final int FULL = 4;
private NearbyAdapter adapter;
private ListView nearby_lv;
private RelativeLayout nearby_lv_header;
private Button list_bottom_btn;
private LinearLayout list_bottom_linear;
private TextView bottom_progress_text;
private RelativeLayout nearby_lv_footer;
private Button list_header_btn;
private LinearLayout list_header_linear;
private TextView heard_progress_text;
private ArrayList<JSONObject> nearby_data = new ArrayList<JSONObject>();
private int lastItem;
private HashMap<String, Drawable> imageCache;
private com.stay.main.ListViewActivity.MyHandler myHandler;
private ProgressDialog dialog;
private int curPage = 1;
private boolean isMember = false;
private int firstItem;
public int count;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initView();
myHandler.sendEmptyMessage(LOAD);
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
DebugUtil.debug("onScrollStateChanged");
//當滾動停止且滾動的總數等於數據的總數,去加載
if (lastItem == count && scrollState == SCROLL_STATE_IDLE) {
DebugUtil.debug("onScrollStateChanged--------next");
if (curPage == 4 && !isMember) {
DebugUtil.show(this, "您不是正式會員,請申請正式會員,");
list_bottom_linear.setVisibility(View.GONE);
} else {
//加載數據
myHandler.sendEmptyMessage(LOAD);
}
return;
}
//當往上拉時更新數據,將data清空然後去重新加載
if (firstItem == 0 && scrollState == SCROLL_STATE_IDLE) {
DebugUtil.debug("onScrollStateChanged--------refresh");
curPage = 0;
myHandler.sendEmptyMessage(LOAD);
}
}
Android安卓破解之逆向分析SO常用的IDA分析技巧 1、結構體的創建及導入,結構體指針等。 以JniNativeInterface, DexHeader為例。 解析
Android Ndk中C與JAVA之間的互相調用 本例實現一個簡單的場景: 1、使用C編寫一個方法,接收1個參數,方法中調用Java的方法。 2、Java類中編寫一
Android之JSON解析,androidjson 做個Android網絡編程的同學一定對於JSON解析一點都不陌生,因為現在我們通過手機向服務器請求資源,服務器給我
RecycleView 滑動到底部,加載更多,recycleview滑動 android.support.v7 包提供了一個新的組件:RecycleView,用以提供一