下面列出了android.widget.ExpandableListView#setEmptyView ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Updates the screen state (current list and other views) when the
* content changes.
*
* @see Activity#onContentChanged()
*/
@Override
public void onContentChanged() {
super.onContentChanged();
View emptyView = findViewById(com.android.internal.R.id.empty);
mList = (ExpandableListView)findViewById(com.android.internal.R.id.list);
if (mList == null) {
throw new RuntimeException(
"Your content must have a ExpandableListView whose id attribute is " +
"'android.R.id.list'");
}
if (emptyView != null) {
mList.setEmptyView(emptyView);
}
mList.setOnChildClickListener(this);
mList.setOnGroupExpandListener(this);
mList.setOnGroupCollapseListener(this);
if (mFinishedStart) {
setListAdapter(mAdapter);
}
mFinishedStart = true;
}
private void initViews() {
mNavigationIndex = getIntent()
.getIntExtra(EXTRA_PRE_LOAD_DATA_INDEX, 0);
llytOperate = (LinearLayout) findViewById(R.id.operate);
btnCancel = (Button) findViewById(R.id.cancel);
btnCancel.setOnClickListener(this);
btnPay = (Button) findViewById(R.id.pay);
btnPay.setOnClickListener(this);
tvEmptyView = (TextView) findViewById(R.id.emptyView);
lvOrders = (ExpandableListView) findViewById(R.id.orders);
lvOrders.setEmptyView(tvEmptyView);
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View footerView = inflater.inflate(R.layout.fv_a6_order, null);
lvOrders.addFooterView(footerView);
mAdapter = new A6OrderExpandableAdapter(this, mLstODBInfos);
lvOrders.setAdapter(mAdapter);
// btnPay.setEnabled(false);
setPanelGone(true);
}
protected void showNoResultsFoundView(final String emptyMsg) {
if (parentView == null || TextUtils.isEmpty(emptyMsg)) return;
ExpandableListView lv = (ExpandableListView)parentView.findViewById(R.id.channelListView);
View emptyView = parentView.findViewById(R.id.channelListEmpty);
if (lv != null && emptyView != null) {
TextView tv = (TextView)emptyView.findViewById(R.id.results_not_found);
tv.setText(emptyMsg);
lv.setEmptyView(emptyView);
}
View progressView = parentView.findViewById(R.id.channelListProgress);
if (progressView != null) {
progressView.setVisibility(View.GONE);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.channel_list, container, false);
OnChildClickListener channelItemListener = new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
JSONObject channelItem = (JSONObject) adapter.getChild(groupPosition, childPosition);
channelSelected(channelItem);
return true;
}
};
ExpandableListView channelsView = (ExpandableListView) view.findViewById(R.id.channelListView);
channelsView.setEmptyView(view.findViewById(R.id.channelListProgress));
channelsView.setAdapter(adapter);
channelsView.setOnChildClickListener(channelItemListener);
PauseOnScrollListener listener = new PauseOnScrollListener(ImageLoader.getInstance(), true, true);
channelsView.setOnScrollListener(listener);
expandAll(view);
return view;
}
/**
* Makes an empty ListView and returns it.
*
* @return ListView
*/
private void _initListView() {
expandableListView = (ExpandableListView) findViewById(R.id.listView);
expandableListView.setTextFilterEnabled(true);
expandableListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
expandableListView.setEmptyView(findViewById(android.R.id.empty));
// Set the data
setAdapter();
// events
this._setListViewEvents();
adapter.notifyDataSetChanged();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.device_services_activity);
gattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
gattServicesList.setOnChildClickListener(this);
final View emptyView = findViewById(R.id.empty_view);
gattServicesList.setEmptyView(emptyView);
dataCharacteristic = (TextView) findViewById(R.id.data_characteristic_uuid);
dataValue = (TextView) findViewById(R.id.data_characteristic_value);
//noinspection ConstantConditions
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
final String deviceName = getDeviceName();
if (TextUtils.isEmpty(deviceName)) {
//noinspection ConstantConditions
actionBar.setTitle(getDeviceAddress());
} else {
//noinspection ConstantConditions
actionBar.setTitle(deviceName);
actionBar.setSubtitle(getDeviceAddress());
}
actionBar.setDisplayHomeAsUpEnabled(true);
}
private void setLoading(final Context context) {
ProgressBar progressBar = (ProgressBar)view.findViewById(R.id.channelListProgress);
ExpandableListView elv = (ExpandableListView)view.findViewById(R.id.channelListView);
View noResultsFound = view.findViewById(R.id.channelListEmpty);
if (elv != null) {
progressBar.setVisibility(View.VISIBLE);
elv.setEmptyView(progressBar);
if (noResultsFound != null) {
noResultsFound.setVisibility(View.GONE);
}
}
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
final View emptyView = View.inflate(container.getContext(), R.layout.list_empty_view, null);
final ExpandableListView channelsView = (ExpandableListView) view.findViewById(R.id.channelListView);
channelsView.setEmptyView(emptyView);
view.findViewById(R.id.channelListProgress).setVisibility(View.GONE);
adapter.configure(genericChannelFrag, view);
return view;
}