MainActivity

public class MainActivity extends ActionBarActivity implements IXListViewListener {
    private XListView xListView;
    private String JSON="http://api.fang.anjuke.com/m/android/1.3/shouye/recInfosV3/?city_id=14&lat=40.04652&lng=116.306033&api_key=androidkey&sig=9317e9634b5fbc16078ab07abb6661c5&macid=45cd2478331b184ff0e15f29aaa89e3e&app=a-ajk&_pid=11738&o=PE-TL10-user+4.4.2+HuaweiPE-TL10+CHNC00B260+ota-rel-keys%2Crelease-keys&from=mobile&m=Android-PE-TL10&cv=9.5.1&cid=14&i=864601026706713&v=4.4.2&qtime=20160411091603&pm=b61&uuid=1848c59c-185d-48d9-b0e9-782016041109&_chat_id=0";
    int i=1;
     private List<Rows> lists = new ArrayList<Rows>();
    ListAd m;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //控件
        xListView  = (XListView) findViewById(R.id.xListView);
        //他们的配置
           xListView.setPullLoadEnable(true);
           xListView.setPullRefreshEnable(true);
           xListView.setXListViewListener(this);

           init();
    }
    private void init() {
        HttpUtils hu = new HttpUtils();
        hu.send(HttpMethod.GET, JSON+i++, new RequestCallBack<String>() {

            @Override
            public void onFailure(HttpException arg0, String arg1) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
                String str = arg0.result;
                Gson g  = new Gson();
                MyObj oj =     g.fromJson(str, MyObj.class);
                List<Rows> list = oj.getResult().getRows();
                 lists = list;
                 m = new ListAd(MainActivity.this, lists);
                  xListView.setAdapter(m);
            }
        });

    }
    @Override
    public void onRefresh() {
        init();
        onLoad();

    }
    private void onLoad() {
          //停止刷新、加载
        xListView.stopRefresh();
        xListView.stopLoadMore();
        // 设置日期格式
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 获取当前系统时间
        String nowTime = df.format(new Date(System.currentTimeMillis()));
        // 释放时提示正在刷新时的当前时间
        xListView.setRefreshTime(nowTime);

    }
    @Override
    public void onLoadMore() {
        HttpUtils hu = new HttpUtils();
        hu.send(HttpMethod.GET, JSON+i++, new RequestCallBack<String>() {

            @Override
            public void onFailure(HttpException arg0, String arg1) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
                String str = arg0.result;
                Gson g  = new Gson();
                MyObj oj =     g.fromJson(str, MyObj.class);
                List<Rows> list = oj.getResult().getRows();
                lists.addAll(list);
                m.notifyDataSetChanged();
            }
        });
        onLoad();
    }

}
时间: 2024-10-11 16:51:52

MainActivity的相关文章

MainActivity.java

package www.wulian1.com.webview; import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.webkit.WebView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState

java.lang.ClassNotFoundException: Didn&#39;t find class &quot;stu.love.neihan.MainActivity&quot; on path: DexPathL

java.lang.ClassNotFoundException: Didn't find class "stu.love.neihan.MainActivity" on path: DexPathList  解决方案: 今天遇到一个Bug: 具体的bug 显示: 10-06 22:34:43.019: E/AndroidRuntime(10813): Caused by: java.lang.ClassNotFoundException: Didn't find class &quo

Android开发 之MainActivity类

一.MainActivity: 1.每个种语言都有一个程序入库(如:C#main函数),而Android程序的入口就是Mani Actiivty函数. 2.Activity是Android的核心类(android.app.Activity),在Activity类有onCreate事件方法,一般用于对Activity进行初始化,并且通过setContentView方法将View放到Activity上,绑定后,Activity会显示View上的控件. MainAcitvity.java文件下的Mai

注意:MainActivity的oncreate方法里不要再inflate布局了(MainActivity里的点击事件无响应)

activity_main已经通过setContentView(R.layout.activity_main);设置给MainActivity, 不要再inflate出新布局,然后findviewbyid,然后得出控件,再对控件进行其他设置,包括设置点击事件等等. 错误做法: 1 @Override 2 protected void onCreate(Bundle savedInstanceState) { 3 super.onCreate(savedInstanceState); 4 setC

Android项目编译的时候出现:Caused by: java.lang.ClassNotFoundException: com.example.aaa.MainActivity

错误类型: 04-28 06:10:15.508: E/AndroidRuntime(849): Caused by: java.lang.ClassNotFoundException: com.example.aaa.MainActivity 04-28 06:10:15.508: E/AndroidRuntime(849): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) 04-28 06:1

Android广播错误.MainActivity$MyReceiver; no empty constructor

广播的定义,如果是内部类,必须为静态类 http://blog.csdn.net/chdjj/article/details/19496567 下面总结一下作为内部类的广播接收者在注册的时候需要注意的地方: 1.清单文件注册广播接收者时,广播接收者的名字格式需要注意.因为是内部类,所以需要在内部类所在的类与内部类之间加上$符号: android:name="com.example.brocastdemo.MainActivity$MyReceiver" 2.内部类在声明时一定要写成静态

Caused by: java.lang.ClassNotFoundException: com.njupt.libgdxbase.MainActivity

在使用libgdx来开发游戏时,如果遇到这种问题.很可能是因为你没有在libgdx的项目中导入Android的现骨干jar包导致的. 解决方法如下: 右击项目---"build path"----->"configure build path"-------->这时候会出现如下图所示的界面.这时候把图中红色的钩所钩中的选项的选上 ------>这时候在clean以下project,close在openproject,这时候一般就能解决问题了...

tools:context=&quot;.MainActivity的作用 (转载)

转自:http://blog.csdn.net/caiwenfeng_for_23/article/details/8373569 <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical=&quo

tools:context=&quot;.MainActivity的作用

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/hello_world" tools:co