Google release the new Gmail app with an alternate way to handle pull down to refresh.
谷歌发布新的Gmail应用程序,以另一种方式处理下拉刷新。
Instead of showing the started hidden row that is pulled down. Gmail displays an animated message overtop of the action bar.
而不是显示已下拉的已启动隐藏行。 Gmail会在操作栏上方显示动画消息。
The message includes an animated horizontal line.
该消息包括动画水平线。
Is this a standard feature of the Android SDK? I can't find anything in the action bar API that would do this.
这是Android SDK的标准功能吗?我在动作栏API中找不到任何可以执行此操作的内容。
6 个解决方案
#1
22
Chris Banes' ActionBar-PullToRefresh library on GitHub probably offers pull-to-refresh functionality closest to GMail app.
Chris Banes在GitHub上的ActionBar-PullToRefresh库可能提供最接近GMail应用程序的pull-to-refresh功能。
See also: Juhani Lehtimäki's analysis of GMail pull-to-refresh.
另见:JuhaniLehtimäki对GMail pull-to-refresh的分析。
#2
48
Google has released support for this directly in the SDK. I am not sure of what version you need to support (that may be an issue).
Google已直接在SDK中发布了对此的支持。我不确定您需要支持哪个版本(这可能是一个问题)。
Check out the official SDK feature info here: http://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html
在这里查看官方SDK功能信息:http://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html
If you are able to use the SDK one, you will be better off, even Chris Banes wrote a post, suggesting the same.
如果你能够使用SDK,你会更好,甚至克里斯巴恩斯写了一篇文章,建议相同。
#3
10
try this...it's work for me.
试试这个...这对我有用。
res/layout/activity_main.xml
RES /布局/ activity_main.xml中
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.swipetorefresh.MainActivity"
tools:ignore="MergeRootFrame" />
res/layout/fragment_main.xml
RES /布局/ fragment_main.xml
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MergeRootFrame" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
MainActivity.java
MainActivity.java
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
public static class PlaceholderFragment extends ListFragment implements OnRefreshListener {
private SwipeRefreshLayout mSwipeRefreshLayout;
private static final int LIST_ITEM_COUNT = 5;
private int mOffset = 0;
private ArrayAdapter<String> mListAdapter;
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
// Configure the swipe refresh layout
mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.container);
mSwipeRefreshLayout.setOnRefreshListener(this);
mSwipeRefreshLayout.setColorScheme(
R.color.swipe_color_1, R.color.swipe_color_2,
R.color.swipe_color_3, R.color.swipe_color_4);
// Put the first batch of countries in the list
mListAdapter = new ArrayAdapter<String>(
getActivity(),
android.R.layout.simple_list_item_1,
android.R.id.text1,
getCountries(mOffset));
setListAdapter(mListAdapter);
return rootView;
}
private List<String> getCountries(int offset) {
ArrayList<String> countriesList = new ArrayList<String>();
for(int i=0; i<LIST_ITEM_COUNT;i++){
countriesList.add(COUNTRIES[offset+i]);
}
mOffset = offset + LIST_ITEM_COUNT;
return countriesList;
}
@Override
public void onRefresh() {
// Start showing the refresh animation
mSwipeRefreshLayout.setRefreshing(true);
// Simulate a long running activity
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
updateCountries();
}
}, 5000);
}
private void updateCountries() {
// Add the next batch of countries to the list
mListAdapter.addAll(getCountries(mOffset));
// Signify that we are done refreshing
mSwipeRefreshLayout.setRefreshing(false);
}
private static final String[] COUNTRIES = {"Afghanistan",
"Albania", "Algeria", "American Samoa", "Andorra", "Angola",
"Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina",
"Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
"Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus",
"Belgium", "Belize", "Benin", "Bermuda", "Bhutan",
"Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil",
"Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi",
"Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands",
"Central African Republic", "Chad", "Chile", "China",
"Christmas Island", "Cocos (Keeling) Islands", "Colombia",
"Comoros", "Democratic Republic of the Congo (Kinshasa)",
"Congo, Republic of(Brazzaville)", "Cook Islands", "Costa Rica",
"Ivory Coast", "Croatia", "Cuba", "Cyprus", "Czech Republic",
"Denmark", "Djibouti", "Dominica", "Dominican Republic",
"East Timor (Timor-Leste)", "Ecuador", "Egypt",
"El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia"};
}
}
#4
3
Chris Banes ( the same guy who implemented the best pull to refresh component for android) also implemented the Gmail
like Pull To Refresh.
Chris Banes(为Android实现了最佳刷新组件的同一个人)也实现了像Pull To Refresh这样的Gmail。
You can find it here: https://github.com/chrisbanes/ActionBar-PullToRefresh
你可以在这里找到它:https://github.com/chrisbanes/ActionBar-PullToRefresh
Note that this project is still under development so the current API may change.
请注意,此项目仍处于开发阶段,因此当前的API可能会发生变化。
#5
1
fragment_main.xml
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.testloading.MainActivity$PlaceholderFragment" >
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
counteries.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="47dp"
android:gravity="center_vertical"
android:textStyle="bold"/>
</LinearLayout>
package com.example.testloading;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class MainActivity extends ActionBarActivity {
private static final String TAG = MainActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
private ListView listView;
private static final int LIST_ITEM_COUNT = 20;
private int mOffset = 0;
private boolean flag_loading;
private MyAdapter adapter;
private List<String> list;
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
listView = (ListView) rootView.findViewById(R.id.list);
list = getCountries(mOffset);
adapter = new MyAdapter(list, getActivity());
listView.setAdapter(adapter);
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view,
int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
Log.d(TAG, "firstVisibleItem : " + firstVisibleItem
+ " , visibleItemCount : " + visibleItemCount
+ " , totalItemCount : " + totalItemCount);
if (firstVisibleItem + visibleItemCount == totalItemCount) {
Log.d(TAG, "ZZZ offSet : " + mOffset);
if (COUNTRIES.length > mOffset) {
if (flag_loading == false) {
Log.d(TAG, "ZZZ inside : ");
flag_loading = true;
additems();
}
}
}
}
});
return rootView;
}
protected void additems() {
list.addAll(getCountries(mOffset));
adapter.notifyDataSetChanged();
listView.invalidate();
flag_loading = false;
}
private List<String> getCountries(int offset) {
ArrayList<String> countriesList = new ArrayList<String>();
for (int i = 0; i < LIST_ITEM_COUNT; i++) {
if (COUNTRIES.length > offset + i) {
countriesList.add(COUNTRIES[offset + i]);
}
}
mOffset = offset + LIST_ITEM_COUNT;
return countriesList;
}
private static final String[] COUNTRIES = { "Afghanistan", "Albania",
"Algeria", "American Samoa", "Andorra", "Angola", "Anguilla",
"Antarctica", "Antigua and Barbuda", "Argentina", "Armenia",
"Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas",
"Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
"Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",
"Bosnia and Herzegovina", "Botswana", "Brazil",
"Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi",
"Cambodia", "Cameroon", "Canada", "Cape Verde",
"Cayman Islands", "Central African Republic", "Chad", "Chile",
"China", "Christmas Island", "Cocos (Keeling) Islands",
"Colombia", "Comoros",
"Democratic Republic of the Congo (Kinshasa)",
"Congo, Republic of(Brazzaville)", "Cook Islands",
"Costa Rica", "Ivory Coast", "Croatia", "Cuba", "Cyprus",
"Czech Republic", "Denmark", "Djibouti", "Dominica",
"Dominican Republic", "East Timor (Timor-Leste)", "Ecuador",
"Egypt", "El Salvador", "Equatorial Guinea", "Eritrea",
"Estonia", "Ethiopia" };
}
}
class MyAdapter extends BaseAdapter {
private List<String> list;
private LayoutInflater layoutInflater;
public MyAdapter(List<String> list, Context context) {
this.list = list;
layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup arg2) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.counteries, null);
viewHolder = new ViewHolder();
viewHolder.textView = (TextView) convertView
.findViewById(R.id.text_view);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.textView.setText(list.get(position));
return convertView;
}
class ViewHolder {
public TextView textView;
}
}
#6
0
Test it. Using: swipeRefreshLayout.setRotation(180f);
测试一下。使用:swipeRefreshLayout.setRotation(180f);
And in your adapter ListView, method getView: view.setRotation(180f);
在你的适配器ListView中,方法getView:view.setRotation(180f);
invert order of your items in List.
在列表中反转项目的顺序。
Or using directly android:rotation="180" in xml.
或者在xml中直接使用android:rotation =“180”。
#1
22
Chris Banes' ActionBar-PullToRefresh library on GitHub probably offers pull-to-refresh functionality closest to GMail app.
Chris Banes在GitHub上的ActionBar-PullToRefresh库可能提供最接近GMail应用程序的pull-to-refresh功能。
See also: Juhani Lehtimäki's analysis of GMail pull-to-refresh.
另见:JuhaniLehtimäki对GMail pull-to-refresh的分析。
#2
48
Google has released support for this directly in the SDK. I am not sure of what version you need to support (that may be an issue).
Google已直接在SDK中发布了对此的支持。我不确定您需要支持哪个版本(这可能是一个问题)。
Check out the official SDK feature info here: http://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html
在这里查看官方SDK功能信息:http://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html
If you are able to use the SDK one, you will be better off, even Chris Banes wrote a post, suggesting the same.
如果你能够使用SDK,你会更好,甚至克里斯巴恩斯写了一篇文章,建议相同。
#3
10
try this...it's work for me.
试试这个...这对我有用。
res/layout/activity_main.xml
RES /布局/ activity_main.xml中
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.swipetorefresh.MainActivity"
tools:ignore="MergeRootFrame" />
res/layout/fragment_main.xml
RES /布局/ fragment_main.xml
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MergeRootFrame" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
MainActivity.java
MainActivity.java
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
public static class PlaceholderFragment extends ListFragment implements OnRefreshListener {
private SwipeRefreshLayout mSwipeRefreshLayout;
private static final int LIST_ITEM_COUNT = 5;
private int mOffset = 0;
private ArrayAdapter<String> mListAdapter;
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
// Configure the swipe refresh layout
mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.container);
mSwipeRefreshLayout.setOnRefreshListener(this);
mSwipeRefreshLayout.setColorScheme(
R.color.swipe_color_1, R.color.swipe_color_2,
R.color.swipe_color_3, R.color.swipe_color_4);
// Put the first batch of countries in the list
mListAdapter = new ArrayAdapter<String>(
getActivity(),
android.R.layout.simple_list_item_1,
android.R.id.text1,
getCountries(mOffset));
setListAdapter(mListAdapter);
return rootView;
}
private List<String> getCountries(int offset) {
ArrayList<String> countriesList = new ArrayList<String>();
for(int i=0; i<LIST_ITEM_COUNT;i++){
countriesList.add(COUNTRIES[offset+i]);
}
mOffset = offset + LIST_ITEM_COUNT;
return countriesList;
}
@Override
public void onRefresh() {
// Start showing the refresh animation
mSwipeRefreshLayout.setRefreshing(true);
// Simulate a long running activity
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
updateCountries();
}
}, 5000);
}
private void updateCountries() {
// Add the next batch of countries to the list
mListAdapter.addAll(getCountries(mOffset));
// Signify that we are done refreshing
mSwipeRefreshLayout.setRefreshing(false);
}
private static final String[] COUNTRIES = {"Afghanistan",
"Albania", "Algeria", "American Samoa", "Andorra", "Angola",
"Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina",
"Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
"Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus",
"Belgium", "Belize", "Benin", "Bermuda", "Bhutan",
"Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil",
"Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi",
"Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands",
"Central African Republic", "Chad", "Chile", "China",
"Christmas Island", "Cocos (Keeling) Islands", "Colombia",
"Comoros", "Democratic Republic of the Congo (Kinshasa)",
"Congo, Republic of(Brazzaville)", "Cook Islands", "Costa Rica",
"Ivory Coast", "Croatia", "Cuba", "Cyprus", "Czech Republic",
"Denmark", "Djibouti", "Dominica", "Dominican Republic",
"East Timor (Timor-Leste)", "Ecuador", "Egypt",
"El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia"};
}
}
#4
3
Chris Banes ( the same guy who implemented the best pull to refresh component for android) also implemented the Gmail
like Pull To Refresh.
Chris Banes(为Android实现了最佳刷新组件的同一个人)也实现了像Pull To Refresh这样的Gmail。
You can find it here: https://github.com/chrisbanes/ActionBar-PullToRefresh
你可以在这里找到它:https://github.com/chrisbanes/ActionBar-PullToRefresh
Note that this project is still under development so the current API may change.
请注意,此项目仍处于开发阶段,因此当前的API可能会发生变化。
#5
1
fragment_main.xml
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.testloading.MainActivity$PlaceholderFragment" >
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
counteries.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="47dp"
android:gravity="center_vertical"
android:textStyle="bold"/>
</LinearLayout>
package com.example.testloading;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class MainActivity extends ActionBarActivity {
private static final String TAG = MainActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
private ListView listView;
private static final int LIST_ITEM_COUNT = 20;
private int mOffset = 0;
private boolean flag_loading;
private MyAdapter adapter;
private List<String> list;
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
listView = (ListView) rootView.findViewById(R.id.list);
list = getCountries(mOffset);
adapter = new MyAdapter(list, getActivity());
listView.setAdapter(adapter);
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view,
int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
Log.d(TAG, "firstVisibleItem : " + firstVisibleItem
+ " , visibleItemCount : " + visibleItemCount
+ " , totalItemCount : " + totalItemCount);
if (firstVisibleItem + visibleItemCount == totalItemCount) {
Log.d(TAG, "ZZZ offSet : " + mOffset);
if (COUNTRIES.length > mOffset) {
if (flag_loading == false) {
Log.d(TAG, "ZZZ inside : ");
flag_loading = true;
additems();
}
}
}
}
});
return rootView;
}
protected void additems() {
list.addAll(getCountries(mOffset));
adapter.notifyDataSetChanged();
listView.invalidate();
flag_loading = false;
}
private List<String> getCountries(int offset) {
ArrayList<String> countriesList = new ArrayList<String>();
for (int i = 0; i < LIST_ITEM_COUNT; i++) {
if (COUNTRIES.length > offset + i) {
countriesList.add(COUNTRIES[offset + i]);
}
}
mOffset = offset + LIST_ITEM_COUNT;
return countriesList;
}
private static final String[] COUNTRIES = { "Afghanistan", "Albania",
"Algeria", "American Samoa", "Andorra", "Angola", "Anguilla",
"Antarctica", "Antigua and Barbuda", "Argentina", "Armenia",
"Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas",
"Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
"Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",
"Bosnia and Herzegovina", "Botswana", "Brazil",
"Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi",
"Cambodia", "Cameroon", "Canada", "Cape Verde",
"Cayman Islands", "Central African Republic", "Chad", "Chile",
"China", "Christmas Island", "Cocos (Keeling) Islands",
"Colombia", "Comoros",
"Democratic Republic of the Congo (Kinshasa)",
"Congo, Republic of(Brazzaville)", "Cook Islands",
"Costa Rica", "Ivory Coast", "Croatia", "Cuba", "Cyprus",
"Czech Republic", "Denmark", "Djibouti", "Dominica",
"Dominican Republic", "East Timor (Timor-Leste)", "Ecuador",
"Egypt", "El Salvador", "Equatorial Guinea", "Eritrea",
"Estonia", "Ethiopia" };
}
}
class MyAdapter extends BaseAdapter {
private List<String> list;
private LayoutInflater layoutInflater;
public MyAdapter(List<String> list, Context context) {
this.list = list;
layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup arg2) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.counteries, null);
viewHolder = new ViewHolder();
viewHolder.textView = (TextView) convertView
.findViewById(R.id.text_view);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.textView.setText(list.get(position));
return convertView;
}
class ViewHolder {
public TextView textView;
}
}
#6
0
Test it. Using: swipeRefreshLayout.setRotation(180f);
测试一下。使用:swipeRefreshLayout.setRotation(180f);
And in your adapter ListView, method getView: view.setRotation(180f);
在你的适配器ListView中,方法getView:view.setRotation(180f);
invert order of your items in List.
在列表中反转项目的顺序。
Or using directly android:rotation="180" in xml.
或者在xml中直接使用android:rotation =“180”。