日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

分別設置listview加載中、空數據、加載數據失敗

系統 2113 0
設置listview加載中,空數據,加載數據失敗三種狀態的顯示.

分別設置listview加載中、空數據、加載數據失敗三種狀態的顯示

分別設置listview加載中、空數據、加載數據失敗三種狀態的顯示

分別設置listview加載中、空數據、加載數據失敗三種狀態的顯示

基本用法:
    
import java.util.ArrayList;
import java.util.Arrays;

import com.kanak.emptylayout.EmptyLayout;


import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Toast;
import android.app.ListActivity;

public class MainActivity extends ListActivity {

	private EmptyLayout mEmptyLayout; // this is required to show different layouts (loading or empty or error)
	private ArrayAdapter<String> mAdapter;
	private View.OnClickListener mErrorClickListener = new OnClickListener() {			
		@Override
		public void onClick(View v) {
			Toast.makeText(MainActivity.this, "Try again button clicked", Toast.LENGTH_LONG).show();			
		}
	};
	
	// the list items
	static final String[] MOVIES = new String[] { 
		"Forrest Gump", 
		"Toy Story", 
		"Saving Private Ryan", 
		"Toy Story 2", 
		"The Green Mile", 
		"Cast Away", 
		"Road to Perdition", 
		"Catch Me If You Can", 
		"The Terminal", 
		"The Polar Express", 
		"The Da Vinci Code", 
		"Angels & Demons", 
		"Toy Story 3", 
		"Extremely Loud & Incredibly Close", 
		"Cloud Atlas", 
		"Captain Phillips", 
		"Toy Story 4",
		"The Lost Symbol" 
	};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		// initialize the empty view
		mEmptyLayout = new EmptyLayout(this, getListView());
		mEmptyLayout.setErrorButtonClickListener(mErrorClickListener);
		
		// populate the list view
		populateList();
	}

	// Triggered when "Empty" button is clicked
	public void onShowEmpty(View view) {
		// clear the list and show the empty layout
		mAdapter.clear();
		mEmptyLayout.showEmpty();
	}

	// Triggered when "Loading" button is clicked
	public void onShowLoading(View view) {
		// clear the list and show the loading layout
		mAdapter.clear();
		mEmptyLayout.showLoading();
	}

	// Triggered when "Error" button is clicked
	public void onShowError(View view) {
		// clear the list and show the error layout
		mAdapter.clear();
		mEmptyLayout.showError();
	}
	
	// Triggered when "List" button is clicked
	public void onShowList(View view) {
		// show the list
		populateList();
	}

	private void populateList() {
		ArrayList<String> list = new ArrayList<String>();
		list.addAll(Arrays.asList(MOVIES));
		mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
		setListAdapter(mAdapter);
	}
}

  

分別設置listview加載中、空數據、加載數據失敗三種狀態的顯示


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 黄冈市| 松江区| 休宁县| 阳谷县| 托里县| 高台县| 方山县| 永善县| 资溪县| 辽宁省| 合肥市| 台湾省| 鄢陵县| 启东市| 富顺县| 内乡县| 吉隆县| 襄垣县| 广河县| 曲阜市| 拉萨市| 佳木斯市| 荔浦县| 平利县| 宁城县| 东山县| 赤壁市| 分宜县| 美姑县| 那曲县| 巴塘县| 郸城县| 晋江市| 五常市| 新平| 开远市| 台山市| 内丘县| 墨玉县| 保康县| 广灵县|