我想SwipeRefreshLayout
在onCreateView
我的MainFragment
. 我想要做的是开始下载事件中的信息,onCreateView
同时我显示 SwipeRefreshLayout 刷新。有任何想法吗?
这是我的 Java 代码中的代码MainFragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
SwipeRefreshLayout swpRfrshLyt= (SwipeRefreshLayout) rootView.findViewById(R.id.swpRfrshLyt);
swpRfrshLyt.setColorSchemeResources(R.color.holo_blue_light,
R.color.holo_green_light,
R.color.holo_orange_light,
R.color.holo_red_light);
swpRfrshLyt.setOnRefreshListener(this);
swpRfrshLyt.setRefreshing(true);
return rootView;
}
这是我的fragment_main.xml
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swpRfrshLyt"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/lstvw_items"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.SwipeRefreshLayout>
我正在使用 Android Studio,这是我的构建 gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:+'
compile 'com.mcxiaoke.volley:library:1.0.+'
}
我已经安装Android SDK Build Tools 21.0.2