當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。