English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
swiperefreshlayout이 드래그 다운으로 작동하는 효과를 구현한 예제입니다. 자세한 내용은 다음과 같습니다
레이아웃 파일:
<?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>
MainActivity:
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.addAll(Arrays.asList("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 refreshHandler.sendEmptyMessageDelayed(REFRESH_STATUS, 1500); } }
이미지 결과:
이것이 본 문서의 전부입니다. 여러분의 학습에 도움이 되길 바랍니다. 또한, 외침 교육에 많이 지지해 주시기를 바랍니다.
선언: 본 문서의 내용은 인터넷에서 가져왔으며, 저작권은 원저자에게 있으며, 인터넷 사용자가 자발적으로 기여하고 업로드한 내용으로, 본 웹사이트는 소유권을 가지지 않으며, 인공 편집을 하지 않았으며, 관련 법적 책임을 부담하지 않습니다. 저작권 침해가 의심되는 내용을 발견하시면, notice#w로 이메일을 보내 주시기 바랍니다.3codebox.com(보내는 이메일에서 #을 @으로 변경하십시오. 신고를 하고 관련 증거를 제공하시면, 사실을 확인하면 즉시 저작권 침해 내용을 삭제할 것입니다。)