Android,androidsdk

來源:互聯網
上載者:User

Android,androidsdk
V4的相容包                                                                           

API                                                                                    

code                                                                                   

布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity" >    <android.support.v4.widget.SwipeRefreshLayout        android:id="@+id/swipe"        android:layout_width="match_parent"        android:layout_height="match_parent" >        <ListView            android:id="@+id/listview"            android:layout_width="fill_parent"            android:layout_height="wrap_content" />    </android.support.v4.widget.SwipeRefreshLayout></RelativeLayout>

MainActivty

@Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        listView = (ListView) findViewById(R.id.listview);        mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);                list = new ArrayList<MyTextClass>();            Map<String, String> maps = new HashMap<String, String>();        maps.put("1", "2");                myHandler = new MyHandler();                client = new MyHttpClient(myHandler);                myThread = new MyThread(client,"http://192.168.1.4/json/index.php",maps,GETJSON);                myHandler.setThread(myThread);                        myHandler.setHandlerExtraHandleMessage(new MyHandler.HandlerExtraHandleMessage()        {            @Override            public void handleMessage(Message msg) {                switch (msg.what) {                case GETJSON:                    String strJson1 = (String) msg.obj;                    Json json1 = new Json(strJson1);                    try {                        list = json1.getMyTextClass();                    } catch (JSONException e) {                        e.printStackTrace();                    }                    myBaseAdapter = new MyBaseAdapter(MainActivity.this, list);                    listView.setAdapter(myBaseAdapter);                    break;                case REFRESH:                    String strJson2 = (String) msg.obj;                    Json json2 = new Json(strJson2);                    //list.clear();                    try {                        list = json2.getMyTextClass();                    } catch (JSONException e) {                        e.printStackTrace();                    }                                        if(myBaseAdapter != null)                    {                        myBaseAdapter.setList(list);                        myBaseAdapter.notifyDataSetChanged();                    }                    else                    {                        MyBaseAdapter myBaseAdapter2 = new MyBaseAdapter(MainActivity.this, list);                        listView.setAdapter(myBaseAdapter2);                    }                    mSwipeLayout.setRefreshing(false);                    break;                default:                    System.out.println("Other Message");                    break;                }                super.handleMessage(msg);            }                    });                Map<String, String> maps2 = new HashMap<String, String>();        maps.put("1", "2");        MyRefreshListener myRefreshListener = new MyRefreshListener(myHandler, maps2, REFRESH);        mSwipeLayout.setOnRefreshListener(myRefreshListener);        mSwipeLayout.setColorScheme(android.R.color.holo_green_dark, android.R.color.holo_green_light,                android.R.color.holo_orange_light, android.R.color.holo_red_light);    }
我是天王蓋地虎的分割線                                                             

原始碼:http://pan.baidu.com/s/1dD1Qx01

listview非同步.zip


android是什

android就是機器人的意思 android手機就是使用安卓系統的手機,由Google開發出來的 和一般智能手機差不多 不知道你說的普通手機是什麼意思 android手機能夠多
 
android是什

android就是機器人的意思 android手機就是使用安卓系統的手機,由Google開發出來的 和一般智能手機差不多 不知道你說的普通手機是什麼意思 android手機能夠多
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.