当前位置: 首页>>代码示例>>Java>>正文


Java ListView.getLastVisiblePosition方法代码示例

本文整理汇总了Java中android.widget.ListView.getLastVisiblePosition方法的典型用法代码示例。如果您正苦于以下问题:Java ListView.getLastVisiblePosition方法的具体用法?Java ListView.getLastVisiblePosition怎么用?Java ListView.getLastVisiblePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ListView的用法示例。


在下文中一共展示了ListView.getLastVisiblePosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updatePodcastRows

import android.widget.ListView; //导入方法依赖的package包/类
private void updatePodcastRows() {
    ListView list = getListView();
    int first = list.getFirstVisiblePosition();
    int last = list.getLastVisiblePosition();
    for (int i = first; i <= last; i++) {
        View view = list.getChildAt(i - first);
        list.getAdapter().getView(i, view, list);
    }
}
 
开发者ID:kalikov,项目名称:lighthouse,代码行数:10,代码来源:PodcastsActivity.java

示例2: notifyItemChanged

import android.widget.ListView; //导入方法依赖的package包/类
/**
 * 局部更新API
 */
public void notifyItemChanged(ListView listview, int position){
    int firstPos = listview.getFirstVisiblePosition();
    int lastPos = listview.getLastVisiblePosition();
    Job job = mData.get(position);
    if(position >= firstPos && position <= lastPos){
        View view = listview.getChildAt(position - firstPos); //NOTE
        DownloadAdapter.VH vh = (DownloadAdapter.VH) view.getTag();
        vh.progress.setProgress(job.progress);
        if(job.progress == 100){
            vh.btn.setText("完成");
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DownloadAdapter.java

示例3: isListViewAlreadyAtBottom

import android.widget.ListView; //导入方法依赖的package包/类
/**
 * 判断 ListView 是否已经滚动到底部
 *
 * @param listView 需要被判断的 ListView
 * @return
 */
public static boolean isListViewAlreadyAtBottom(ListView listView) {
    if (listView.getAdapter() == null || listView.getHeight() == 0) {
        return false;
    }

    if (listView.getLastVisiblePosition() == listView.getAdapter().getCount() - 1) {
        View lastItemView = listView.getChildAt(listView.getChildCount() - 1);
        if (lastItemView != null && lastItemView.getBottom() == listView.getHeight()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:coopese,项目名称:qmui,代码行数:20,代码来源:QMUIViewHelper.java

示例4: menuItemContentChanged

import android.widget.ListView; //导入方法依赖的package包/类
/**
 * Notifies the menu that the contents of the menu item specified by {@code menuRowId} have
 * changed.  This should be called if icons, titles, etc. are changing for a particular menu
 * item while the menu is open.
 * @param menuRowId The id of the menu item to change.  This must be a row id and not a child
 *                  id.
 */
public void menuItemContentChanged(int menuRowId) {
    // Make sure we have all the valid state objects we need.
    if (mAdapter == null || mMenu == null || mPopup == null || mPopup.getListView() == null) {
        return;
    }

    // Calculate the item index.
    int index = -1;
    int menuSize = mMenu.size();
    for (int i = 0; i < menuSize; i++) {
        if (mMenu.getItem(i).getItemId() == menuRowId) {
            index = i;
            break;
        }
    }
    if (index == -1) return;

    // Check if the item is visible.
    ListView list = mPopup.getListView();
    int startIndex = list.getFirstVisiblePosition();
    int endIndex = list.getLastVisiblePosition();
    if (index < startIndex || index > endIndex) return;

    // Grab the correct View.
    View view = list.getChildAt(index - startIndex);
    if (view == null) return;

    // Cause the Adapter to re-populate the View.
    list.getAdapter().getView(index, view, list);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:38,代码来源:AppMenu.java

示例5: onLoadFinished

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onLoadFinished(final Loader<Cursor> loader, final Cursor data) {
	// Here we have to restore the old saved scroll position, or scroll to the bottom if before adding new events it was scrolled to the bottom.  
	final ListView list = getListView();
	final int position = mLogScrollPosition;
	final boolean scrolledToBottom = position == LOG_SCROLLED_TO_BOTTOM || (list.getCount() > 0 && list.getLastVisiblePosition() == list.getCount() - 1);

	mLogAdapter.swapCursor(data);

	if (position > LOG_SCROLL_NULL) {
		list.setSelectionFromTop(position, 0);
	} else {
		if (scrolledToBottom)
			list.setSelection(list.getCount() - 1);
	}
	mLogScrollPosition = LOG_SCROLL_NULL;
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:18,代码来源:UARTLogFragment.java

示例6: updateProgressPartly

import android.widget.ListView; //导入方法依赖的package包/类
/**
 * 单个更新某个条目   只有可见的时候更新progress,
 * @param progress 当前进度
 * @param position 位置
 * @param lv_message Listview
    */
public static void updateProgressPartly(int progress,int position,ListView lv_message){
	int firstVisiblePosition = lv_message.getFirstVisiblePosition();
	int lastVisiblePosition = lv_message.getLastVisiblePosition();
	if(position>=firstVisiblePosition && position<=lastVisiblePosition){
		View view = lv_message.getChildAt(position - firstVisiblePosition);
		if(view.getTag() instanceof ImageMessageHolder){
			ImageMessageHolder vh = (ImageMessageHolder)view.getTag();
			vh.sobot_pic_progress_round.setProgress(progress);
		}
	}
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:18,代码来源:ChatUtils.java

示例7: isListViewAlreadyAtBottom

import android.widget.ListView; //导入方法依赖的package包/类
/**
 * 判断 ListView 是否已经滚动到底部。
 *
 * @param listView 需要被判断的 ListView。
 * @return ListView 已经滚动到底部则返回 true,否则返回 false。
 */
public static boolean isListViewAlreadyAtBottom(ListView listView) {
    if (listView.getAdapter() == null || listView.getHeight() == 0) {
        return false;
    }

    if (listView.getLastVisiblePosition() == listView.getAdapter().getCount() - 1) {
        View lastItemView = listView.getChildAt(listView.getChildCount() - 1);
        if (lastItemView != null && lastItemView.getBottom() == listView.getHeight()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:20,代码来源:QMUIViewHelper.java

示例8: getViewHolderByIndex

import android.widget.ListView; //导入方法依赖的package包/类
public static Object getViewHolderByIndex(ListView listView, int index) {
	int firstVisibleFeedPosition = listView.getFirstVisiblePosition() - listView.getHeaderViewsCount();
	int lastVisibleFeedPosition = listView.getLastVisiblePosition() - listView.getHeaderViewsCount();

	//只有获取可见区域的
	if (index >= firstVisibleFeedPosition && index <= lastVisibleFeedPosition) {
		View view = listView.getChildAt(index - firstVisibleFeedPosition);
		Object tag = view.getTag();
		return tag;
	} else {
		return null;
	}
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:14,代码来源:ListViewUtil.java

示例9: onMsgRecv

import android.widget.ListView; //导入方法依赖的package包/类
private void onMsgRecv(MessageEntity entity) {
    logger.d("message_activity#onMsgRecv");

    imService.getUnReadMsgManager().ackReadMsg(entity);
    logger.d("chat#start pushList");
    pushList(entity);
    ListView lv = lvPTR.getRefreshableView();
    if (lv != null) {

        if (lv.getLastVisiblePosition() < adapter.getCount()) {
            textView_new_msg_tip.setVisibility(View.VISIBLE);
        } else {
            scrollToBottomListItem();
        }
    }
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:17,代码来源:MessageActivity.java

示例10: isIdVisible

import android.widget.ListView; //导入方法依赖的package包/类
public static boolean isIdVisible(ListView listView, long id) {
    final int firstVisible = listView.getFirstVisiblePosition();
    final int lastVisible = listView.getLastVisiblePosition();

    for (int pos = firstVisible; pos <= lastVisible; pos++) {
        long posId = listView.getItemIdAtPosition(pos);

        if (posId == id) {
            return true;
        }
    }

    return false;
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:15,代码来源:ListViewUtils.java

示例11: onSaveInstanceState

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onSaveInstanceState(final Bundle outState) {
	super.onSaveInstanceState(outState);

	// Save the last log list view scroll position
	final ListView list = getListView();
	final boolean scrolledToBottom = list.getCount() > 0 && list.getLastVisiblePosition() == list.getCount() - 1;
	outState.putInt(SIS_LOG_SCROLL_POSITION, scrolledToBottom ? LOG_SCROLLED_TO_BOTTOM : list.getFirstVisiblePosition());
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:10,代码来源:UARTLogFragment.java

示例12: isLastMessageVisible

import android.widget.ListView; //导入方法依赖的package包/类
public static boolean isLastMessageVisible(ListView messageListView) {
	if(messageListView == null || messageListView.getAdapter() == null) {
		return false;
	}
	
    if (messageListView.getLastVisiblePosition() >= messageListView.getAdapter().getCount() - 1 - messageListView.getFooterViewsCount()) {
        return true;
    } else {
        return false;
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:12,代码来源:ListViewUtil.java

示例13: isRowInIconLoadingRange

import android.widget.ListView; //导入方法依赖的package包/类
private boolean isRowInIconLoadingRange(long id) {
    ListView list = getListView();
    int count = adapter.getCount();
    int first = list.getFirstVisiblePosition();
    int last = list.getLastVisiblePosition();
    int visible = last - first + 1;
    int start = Math.max(0, first - visible / 2);
    int end = Math.min(count - 1, last + visible / 2);
    for (int i = start; i <= end; i++) {
        if (id == adapter.getItemId(i)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:kalikov,项目名称:lighthouse,代码行数:16,代码来源:PodcastsActivity.java

示例14: updatePodcastRow

import android.widget.ListView; //导入方法依赖的package包/类
private void updatePodcastRow(long id) {
    ListView list = getListView();
    int first = list.getFirstVisiblePosition();
    int last = list.getLastVisiblePosition();
    for (int i = first; i <= last; i++) {
        if (id == list.getItemIdAtPosition(i)) {
            View view = list.getChildAt(i - first);
            list.getAdapter().getView(i, view, list);
            break;
        }
    }
}
 
开发者ID:kalikov,项目名称:lighthouse,代码行数:13,代码来源:PodcastsActivity.java

示例15: onWordListClicked

import android.widget.ListView; //导入方法依赖的package包/类
void onWordListClicked(final View v) {
    // Note : v is the preference view
    final ViewParent parent = v.getParent();
    // Just in case something changed in the framework, test for the concrete class
    if (!(parent instanceof ListView)) return;
    final ListView listView = (ListView)parent;
    final int indexToOpen;
    // Close all first, we'll open back any item that needs to be open.
    final boolean wasOpen = mInterfaceState.isOpen(mWordlistId);
    mInterfaceState.closeAll();
    if (wasOpen) {
        // This button being shown. Take note that we don't want to open any button in the
        // loop below.
        indexToOpen = -1;
    } else {
        // This button was not being shown. Open it, and remember the index of this
        // child as the one to open in the following loop.
        mInterfaceState.setOpen(mWordlistId, mStatus);
        indexToOpen = listView.indexOfChild(v);
    }
    final int lastDisplayedIndex =
            listView.getLastVisiblePosition() - listView.getFirstVisiblePosition();
    // The "lastDisplayedIndex" is actually displayed, hence the <=
    for (int i = 0; i <= lastDisplayedIndex; ++i) {
        final ButtonSwitcher buttonSwitcher = (ButtonSwitcher)listView.getChildAt(i)
                .findViewById(R.id.wordlist_button_switcher);
        if (i == indexToOpen) {
            buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(mStatus));
        } else {
            buttonSwitcher.setStatusAndUpdateVisuals(ButtonSwitcher.STATUS_NO_BUTTON);
        }
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:34,代码来源:WordListPreference.java


注:本文中的android.widget.ListView.getLastVisiblePosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。