本文整理汇总了Java中android.widget.ListView.setEmptyView方法的典型用法代码示例。如果您正苦于以下问题:Java ListView.setEmptyView方法的具体用法?Java ListView.setEmptyView怎么用?Java ListView.setEmptyView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ListView
的用法示例。
在下文中一共展示了ListView.setEmptyView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SearchableSpinner
import android.widget.ListView; //导入方法依赖的package包/类
public SearchableSpinner(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mContext = context;
getAttributeSet(attrs, defStyleAttr, defStyleRes);
final LayoutInflater factory = LayoutInflater.from(context);
factory.inflate(R.layout.view_searchable_spinner, this, true);
mSpinnerListContainer = (LinearLayout) factory.inflate(R.layout.view_list, this, false);
mSpinnerListView = (ListView) mSpinnerListContainer.findViewById(R.id.LstVw_SpinnerListView);
if (mListItemDivider != null) {
mSpinnerListView.setDivider(mListItemDivider);
mSpinnerListView.setDividerHeight(mListDividerSize);
}
mEmptyTextView = (TextView) mSpinnerListContainer.findViewById(R.id.TxtVw_EmptyText);
mSpinnerListView.setEmptyView(mEmptyTextView);
}
示例2: onBindDialogView
import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onBindDialogView(View view) {
mListView = (ListView) view.findViewById(R.id.icon_list);
mListView.setOnItemClickListener(this);
mListView.setEmptyView(view.findViewById(R.id.info_list_empty));
mBtnResetList = (Button) view.findViewById(R.id.btnReset);
mBtnResetList.setOnClickListener(this);
mDescription = (TextView) view.findViewById(R.id.description);
mDivider = (View) view.findViewById(R.id.divider);
super.onBindView(view);
setData();
}
示例3: onCreateView
import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.family_tab_medicines_list, container, false);
medicineFamilyListView = (ListView) view.findViewById(R.id.medicine_family_list_view);
medicineFamilyListView.setEmptyView(view.findViewById(R.id.medicine_family_list_empty));
searchMedicineBtn = (FloatingActionButton) view.findViewById(R.id.search_medicines_family_btn);
searchMedicineBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SearchMedicineDialogHelper searchMedicineDialogHelper = new SearchMedicineDialogHelper();
searchMedicineDialogHelper.initializeSearchFamilyMedicineDialog(MedicinesFamilyListTabFragment.this);
}
});
Map<String, User> userIdToUserObjMap = SessionManager.getFamilyUserMembers();
List<User> familyUsers = new ArrayList<>(userIdToUserObjMap.values());
List<Medicine> sharedMedicinesFromFamilyMembers = prepareSharedMedicinesFromFamilyMembers(familyUsers);
FamilyMedicineItemArrayAdapter familyMedicineItemArrayAdapter = new FamilyMedicineItemArrayAdapter(getContext(), R.id.medicine_family_list_view, sharedMedicinesFromFamilyMembers);
medicineFamilyListView.setAdapter(familyMedicineItemArrayAdapter);
initializeFirebaseListeners();
return view;
}
示例4: QsDetailItemsList
import android.widget.ListView; //导入方法依赖的package包/类
private QsDetailItemsList(LinearLayout view) {
mView = view;
mListView = (ListView) mView.findViewById(android.R.id.list);
mListView.setOnTouchListener(new OnTouchListener() {
// Setting on Touch Listener for handling the touch inside ScrollView
@Override
public boolean onTouch(View v, MotionEvent event) {
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
mEmpty = mView.findViewById(android.R.id.empty);
mEmpty.setVisibility(View.GONE);
mEmptyText = (TextView) mEmpty.findViewById(android.R.id.title);
mEmptyIcon = (ImageView) mEmpty.findViewById(android.R.id.icon);
mListView.setEmptyView(mEmpty);
}
示例5: init
import android.widget.ListView; //导入方法依赖的package包/类
/**
* Init views in the fragment
*
* @param rootView Fragment view
*/
private void init(View rootView) {
Soras = new ArrayList<Sora>();
adapter = new PartShowAdapter(getActivity(), Soras);
partsList = (ListView) rootView.findViewById(R.id.listView);
partsList.setEmptyView(rootView.findViewById(R.id.progressBar3));
partsList.setAdapter(adapter);
partsList.setActivated(true);
partsList.setOnItemClickListener(this);
adapter.addAll(MainActivity.soraListModified);
adapter.notifyDataSetChanged();
}
示例6: onCreate
import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_hosts);
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.view_logo);
mHostsListView = (ListView) findViewById(R.id.hosts_listview);
mHostsListView.setEmptyView(findViewById(R.id.empty_hosts_textview));
registerForContextMenu(mHostsListView);
mHostsListView.setOnItemClickListener(this);
hostsAdapter = new HostsCursorAdapter(HostActivity.this, null, true);
mHostsListView.setAdapter(hostsAdapter);
getSupportLoaderManager().initLoader(0, null, this);
}
示例7: onCreateView
import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fr_bookmarks_list, container,
false);
mBookmarksListView = (ListView) rootView
.findViewById(R.id.bookmarks_list);
mBookmarksListView.setEmptyView(rootView
.findViewById(R.id.empty_bookmarks_textview));
mBookmarksListView.setOnItemClickListener(this);
return rootView;
}
示例8: onViewCreated
import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final ListView listView = findAdapterView();
listView.setEmptyView(getEmptyView());
listView.setOnItemClickListener(this);
}
示例9: init
import android.widget.ListView; //导入方法依赖的package包/类
/**
* Function to init views
*/
private void init() {
Intent intent = getIntent();
searchText = intent.getStringExtra(AppConstants.General.SEARCH_TEXT);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(getString(R.string.search));
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
resultsInfo = (TextView) findViewById(R.id.textView13);
ayas = new ArrayList<Aya>();
searchResults = (ListView) findViewById(R.id.listView3);
searchResults.setOnItemClickListener(this);
searchResults.setEmptyView(findViewById(R.id.progressBar3));
if(searchText.contains("%")||searchText.contains("%")||searchText.contains("%")||searchText.contains("_")||searchText.contains("@")||searchText.contains("$")||searchText.contains(" % ")||searchText.contains("^")||searchText.contains("&")||searchText.contains("*")||searchText.contains("(")||searchText.contains(")")||searchText.contains("-")||searchText.contains("?")||searchText.contains(">")||searchText.contains("<")||searchText.contains("'")||searchText.contains(":")||searchText.contains(";")||searchText.contains("+")||searchText.contains("=")||searchText.contains("/")||searchText.contains("_")||searchText.contains(".")||searchText.contains(",")||searchText.contains("`")){
resultsInfo.setText(" 0 results for : "+searchText);
findViewById(R.id.progressBar3).setVisibility(View.GONE);
searchResults.setEmptyView(findViewById(R.id.empty));
}else{
adapter = new SearchShowAdapter(this, searchText, ayas);
searchResults.setAdapter(adapter);
new SearchResults().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
示例10: init
import android.widget.ListView; //导入方法依赖的package包/类
/**
* Function to init activity view
*/
private void init() {
//init views
adapter = new TranslationAdapter(this);
translationManagmentList = (ListView) findViewById(R.id.download);
translationManagmentList.setOnItemClickListener(this);
translationManagmentList.setTextFilterEnabled(true);
translationManagmentList.setEmptyView(findViewById(R.id.progressBar3));
translationManagmentList.setAdapter(adapter);
//async thread to load translations
new TafaseerLists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
示例11: onCreate
import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFlags(LayoutParams.FLAG_NOT_TOUCH_MODAL, LayoutParams.FLAG_NOT_TOUCH_MODAL);
getWindow().setFlags(LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
// Notify the application that the activity has started
CustomApplication app = (CustomApplication)getApplication();
app.setAutoScraperActive(true);
mScraper = new Scraper(this);
// Check if the intent which created this activity contains a folder path
Uri folderUri = getIntent().getData();
if (folderUri != null) {
mFolderMode = true;
// FIXME: this is broken for smb:// files
mFolderPath = folderUri.getPath();
if (DBG) Log.d(TAG, "onCreate : search in folder " + mFolderPath);
}
else {
mFolderMode = false;
mFolderPath = null;
if (DBG) Log.d(TAG, "onCreate : search in the full database");
}
setContentView(R.layout.auto_scraper_main);
mMainView = findViewById(R.id.main_view);
mAbortButton = (Button)findViewById(R.id.abort_button);
mAbortButton.setOnClickListener(this);
mExitButton = (Button)findViewById(R.id.exit_button);
mExitButton.setOnClickListener(this);
mListView = (ListView) findViewById(R.id.list_items);
mListView.setTextFilterEnabled(true);
mListView.setCacheColorHint(0);
mListView.setSelector(R.drawable.list_selector_no_background);
mListView.setOnCreateContextMenuListener(this);
mListView.setOnScrollListener(this);
mListView.setOnKeyListener(this);
mActivityFileCursor = getFileListCursor();
getColumnIndices(mActivityFileCursor);
buildFileProperties(mActivityFileCursor);
mAdapterFileCursor = buildAdapterCursor(mActivityFileCursor);
mAdapter = new AutoScraperAdapter(getApplication(), this,
R.layout.auto_scraper_item,
mAdapterFileCursor);
mListView.setAdapter(mAdapter);
/*
if (!mListView.isInTouchMode()) {
// The application is remotely controlled => set the focus by default
// on the Cancel button so that the user can abort the task with a
// single click instead of navigating the full ListView
mAbortButton.requestFocus();
}
*/
mEmptyView = buildEmptyView();
mListView.setEmptyView(mEmptyView);
updateControlButtons(false);
if (mFileCount > 0) {
mMainView.setVisibility(View.VISIBLE);
}
else {
mMainView.setVisibility(View.GONE);
}
mIsLargeScreen = getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)|| TVUtils.isTV(this);
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "AutoScraperActivity");
}
示例12: onViewCreated
import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// notify user if permission isn't granted
Permissions.notifyIfNotGranted(getContext(), Permissions.READ_SMS);
Permissions.notifyIfNotGranted(getContext(), Permissions.READ_CONTACTS);
// cursor adapter
cursorAdapter = new SMSConversationsListCursorAdapter(getContext());
// on row click listener (receives clicked row)
cursorAdapter.setOnClickListener(new OnRowClickListener());
// on row long click listener (receives clicked row)
cursorAdapter.setOnLongClickListener(new OnRowLongClickListener());
// add cursor listener to the list
listView = (ListView) view.findViewById(R.id.rows_list);
listView.setAdapter(cursorAdapter);
// on list empty comment
TextView textEmptyView = (TextView) view.findViewById(R.id.text_empty);
listView.setEmptyView(textEmptyView);
// init internal broadcast event receiver
internalEventBroadcast = new InternalEventBroadcast() {
// SMS was written
@Override
public void onSMSWasWritten(String phoneNumber) {
ContactsAccessHelper db = ContactsAccessHelper.getInstance(getContext());
int threadId = db.getSMSThreadIdByNumber(getContext(), phoneNumber);
if (threadId >= 0 &&
// refresh cached list view items
cursorAdapter.invalidateCache(threadId)) {
cursorAdapter.notifyDataSetChanged();
} else {
// reload all list view items
loadListViewItems(false, false);
}
}
// SMS was deleted
@Override
public void onSMSWasDeleted(String phoneNumber) {
// reload all list view items
loadListViewItems(false, false);
}
// SMS thread was read
@Override
public void onSMSThreadWasRead(int threadId) {
// refresh cached list view items
cursorAdapter.invalidateCache(threadId);
cursorAdapter.notifyDataSetChanged();
}
};
internalEventBroadcast.register(getContext());
// load SMS conversations to the list
loadListViewItems(listPosition, true, true);
}
示例13: onCreate
import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.earthquake_activity);
// Find a reference to the {@link ListView} in the layout
ListView earthquakeListView = (ListView) findViewById(R.id.list);
mEmptyStateTextView = (TextView) findViewById(R.id.empty_view);
earthquakeListView.setEmptyView(mEmptyStateTextView);
// Create a new adapter that takes an empty list of earthquakes as input
mAdapter = new EarthquakeAdapter(this, new ArrayList<Earthquake>());
// Set the adapter on the {@link ListView}
// so the list can be populated in the user interface
earthquakeListView.setAdapter(mAdapter);
// Set an item click listener on the ListView, which sends an intent to a web browser
// to open a website with more information about the selected earthquake.
earthquakeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
// Find the current earthquake that was clicked on
Earthquake currentEarthquake = (Earthquake) mAdapter.getItem(position);
// Convert the String URL into a URI object (to pass into the Intent constructor)
Uri earthquakeUri = Uri.parse(currentEarthquake.getUrl());
// Create a new intent to view the earthquake URI
Intent websiteIntent = new Intent(Intent.ACTION_VIEW, earthquakeUri);
// Send the intent to launch a new activity
startActivity(websiteIntent);
}
});
// Get a reference to the ConnectivityManager to check state of network connectivity
ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
// Get details on the currently active default data network
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
// If there is a network connection, fetch data
if (networkInfo != null && networkInfo.isConnected()) {
// Get a reference to the LoaderManager, in order to interact with loaders.
LoaderManager loaderManager = getLoaderManager();
// Initialize the loader. Pass in the int ID constant defined above and pass in null for
// the bundle. Pass in this activity for the LoaderCallbacks parameter (which is valid
// because this activity implements the LoaderCallbacks interface).
loaderManager.initLoader(EARTHQUAKE_LOADER_ID, null, this);
} else {
// Otherwise, display error
// First, hide loading indicator so error message will be visible
View loadingIndicator = findViewById(R.id.loading_indicator);
loadingIndicator.setVisibility(View.GONE);
// Update empty state with no connection error message
mEmptyStateTextView.setText(R.string.no_internet_connection);
}
}
示例14: onCreateView
import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
rootView = inflater.inflate(R.layout.layout, container, false);
loadingIndicator = (ProgressBar)rootView.findViewById(R.id.loading_indicator);
// Find a reference to the {@link ListView} in the layout
ListView newsListView = (ListView) rootView.findViewById(R.id.list);
mEmptyStateTextView = (TextView) rootView.findViewById(R.id.empty_view);
newsListView.setEmptyView(mEmptyStateTextView);
// Create an {@link WordAdapter}, whose data source is a list of {@link Word}s. The
// adapter knows how to create list items for each item in the list.
mAdapter = new NewsAdapter(getActivity(), new ArrayList<News>());
// Make the {@link ListView} use the {@link WordAdapter} we created above, so that the
// {@link ListView} will display list items for each {@link Word} in the list.
newsListView.setAdapter(mAdapter);
// Set an item click listener on the ListView, which sends an intent to a web browser
// to open a website with more information about the selected earthquake.
newsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
// Find the current earthquake that was clicked on
News currentEarthquake = mAdapter.getItem(position);
// Convert the String URL into a URI object (to pass into the Intent constructor)
Uri newsUri = Uri.parse(currentEarthquake.getUrl());
// Create a new intent to view the earthquake URI
Intent websiteIntent = new Intent(Intent.ACTION_VIEW, newsUri);
// Send the intent to launch a new activity
startActivity(websiteIntent);
}
});
// Get a reference to the ConnectivityManager to check state of network connectivity
ConnectivityManager connMgr = (ConnectivityManager)
getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
// Get details on the currently active default data network
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
// If there is a network connection, fetch data
if (networkInfo != null && networkInfo.isConnected()) {
loadingIndicator.setVisibility(View.VISIBLE);
// Get a reference to the LoaderManager, in order to interact with loaders.
LoaderManager loaderManager = getLoaderManager();
// Initialize the loader. Pass in the int ID constant defined above and pass in null for
// the bundle. Pass in this activity for the LoaderCallbacks parameter (which is valid
// because this activity implements the LoaderCallbacks interface).
loaderManager.initLoader(GENERAL_LOADER_ID, null, this);
} else {
// Otherwise, display error
// First, hide loading indicator so error message will be visible
// View loadingIndicator = rootView.findViewById(R.id.loading_indicator);
loadingIndicator.setVisibility(View.GONE);
// Update empty state with no connection error message
mEmptyStateTextView.setText(R.string.no_internet_connection);
}
return rootView;
}
示例15: onCreate
import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
String themes = sharedPrefs.getString(
getString(R.string.settings_themes_key),
getString(R.string.settings_themes_default));
switch (themes) {
case "dark":
setTheme(R.style.AppTheme);
break;
case "light":
setTheme(R.style.AppTheme_Light);
break;
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quake);
dialog = new Dialog(this);
Boolean isFirstRun = getSharedPreferences("PREFERENCE", MODE_PRIVATE)
.getBoolean("isFirstRun", true);
if (isFirstRun) {
dialog.setContentView(R.layout.instruction_dialog);
dialog.show();
getSharedPreferences("PREFERENCE", MODE_PRIVATE).edit()
.putBoolean("isFirstRun", false).apply();
}
listView = (ListView) findViewById(R.id.listView);
progressBar = (ProgressBar) findViewById(R.id.pbar);
emptyView = (TextView) findViewById(R.id.empty_view);
emptyDesc = (TextView) findViewById(R.id.empty_view_desc);
emptyImageView = (ImageView) findViewById(R.id.empty_imageview);
mySwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh);
listView.setEmptyView(emptyView);
listView.setEmptyView(emptyImageView);
listView.setEmptyView(emptyDesc);
loaderManager = getLoaderManager();
mySwipeRefreshLayout.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
loaderManager.restartLoader(0, null, QuakeActivity.this);
}
}
);
if (googleServicesAvailable()) {
checkConnection();
if (networkInfo != null && networkInfo.isConnected()) {
loaderManager.initLoader(0, null, QuakeActivity.this);
} else {
progressBar.setVisibility(View.GONE);
emptyView.setText(R.string.noInternet);
emptyDesc.setText(R.string.emptyDesc);
emptyImageView.setImageResource(R.drawable.no_connection);
}
}
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
checkConnection();
if (networkInfo != null && networkInfo.isConnected()) {
Intent intent = new Intent(QuakeActivity.this, MapsActivity.class);
startActivity(intent);
} else {
Toast.makeText(QuakeActivity.this, "No Internet Connection. Please Check your connectivity and try again.",Toast.LENGTH_SHORT).show();
}
}
});
}