<?xml version="1.0" encoding="utf-8"?>
<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"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener{
private static final int REFRESH_STATUS =0;
private ListView myListView;
private SwipeRefreshLayout mySwipeRefreshLayout;
private ArrayAdapter<String> listAdapter;
private List<String> listIDE = new ArrayList<String>(Arrays.asList("Visual Studio", "Android Studio", "Eclipse", "Xcode"));
private Handler refreshHandler = new Handler()
{
public void handleMessage(android.os.Message msg)
{
switch (msg.what)
{
case REFRESH_STATUS:
listIDE.removeAll(listIDE);
listIDE.addAll(Arrays.asList("C#", "Java", "C++","Object-C"));
listAdapter.notifyDataSetChanged();
mySwipeRefreshLayout.setRefreshing(false);
break;
}
};
};
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myListView = (ListView) findViewById(R.id.listView);
mySwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
mySwipeRefreshLayout.setOnRefreshListener(this);
mySwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
android.R.color.holo_orange_light, android.R.color.holo_red_light);
listAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,listIDE);
myListView.setAdapter(listAdapter);
}
@Override
public void onRefresh() {
refreshHandler.sendEmptyMessageDelayed(REFRESH_STATUS, 1500);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有