當前位置: 首頁>>代碼示例>>Java>>正文


Java ListView.getChildCount方法代碼示例

本文整理匯總了Java中android.widget.ListView.getChildCount方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.getChildCount方法的具體用法?Java ListView.getChildCount怎麽用?Java ListView.getChildCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ListView的用法示例。


在下文中一共展示了ListView.getChildCount方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setListItemsStyle

import android.widget.ListView; //導入方法依賴的package包/類
private static void setListItemsStyle(ConfigBean bean) {
    if(bean.type == DefaultConfig.TYPE_MD_SINGLE_CHOOSE || bean.type == DefaultConfig.TYPE_MD_MULTI_CHOOSE){
        ListView listView =  bean.alertDialog.getListView();
       // listView.getAdapter().
        if(listView!=null && listView.getAdapter() !=null){
            int count = listView.getChildCount();
            for(int i=0;i<count;i++){
                View childAt = listView.getChildAt(i);
                if(childAt ==null){
                    continue;
                }
                CheckedTextView itemView = (CheckedTextView) childAt.findViewById(android.R.id.text1);
                Log.e("dd",itemView+"-----"+ i);
                if(itemView !=null) {
                    itemView.setCheckMarkDrawable(R.drawable.bg_toast);
                    //itemView.setCheckMarkTintList();

                   // itemView.setCheckMarkTintList();
                    //itemView.setCheckMarkTintList();

                }

            }

        }

    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:29,代碼來源:Tool.java

示例2: getViewByPosition

import android.widget.ListView; //導入方法依賴的package包/類
/**
 * @see <a href="http://stackoverflow.com/questions/24811536/android-listview-get-item-view-by-position" >android - listview get item view by position
</a>
 * @param pos
 * @param listView
 * @return
 */
public static View getViewByPosition(int pos, ListView listView) {
    final int firstListItemPosition = listView.getFirstVisiblePosition();
    final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;

    if (pos < firstListItemPosition || pos > lastListItemPosition ) {
        return listView.getAdapter().getView(pos, null, listView);
    } else {
        final int childIndex = pos - firstListItemPosition;
        return listView.getChildAt(childIndex);
    }
}
 
開發者ID:ProjectFishpond,項目名稱:TPondof,代碼行數:19,代碼來源:Utils.java

示例3: invalidateSuggestionViews

import android.widget.ListView; //導入方法依賴的package包/類
/**
 * Invalidates all of the suggestion views in the list.  Only applicable when this
 * is visible.
 */
public void invalidateSuggestionViews() {
    if (!isShown()) return;
    ListView suggestionsList = mSuggestionList;
    for (int i = 0; i < suggestionsList.getChildCount(); i++) {
        if (suggestionsList.getChildAt(i) instanceof SuggestionView) {
            suggestionsList.getChildAt(i).postInvalidateOnAnimation();
        }
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:14,代碼來源:LocationBarLayout.java

示例4: loadImage

import android.widget.ListView; //導入方法依賴的package包/類
private void loadImage(ListView listView) {
    if (listView != null) {
        try {
            int count = listView.getChildCount();
            for (int i = 0; i < count; i++) {
                Object tag = listView.getChildAt(i).getTag();
                if (tag != null) {
                    ViewHolder holder = (ViewHolder) tag;
                    Object t1 = holder.iv_1.getTag();
                    if (t1 != null) {
                        ImageDownloader.getInstance().download(holder.iv_1, (String) t1);
                        holder.iv_1.setTag(null);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:21,代碼來源:TopRecommendFragment.java

示例5: canTargetScrollVertically

import android.widget.ListView; //導入方法依賴的package包/類
public boolean canTargetScrollVertically(int direction) {
    ListView target = this.mTarget;
    int itemCount = target.getCount();
    if (itemCount == 0) {
        return false;
    }
    int childCount = target.getChildCount();
    int firstPosition = target.getFirstVisiblePosition();
    int lastPosition = firstPosition + childCount;
    if (direction > 0) {
        if (lastPosition >= itemCount && target.getChildAt(childCount - 1).getBottom() <= target.getHeight()) {
            return false;
        }
    } else if (direction >= 0) {
        return false;
    } else {
        if (firstPosition <= 0 && target.getChildAt(0).getTop() >= 0) {
            return false;
        }
    }
    return true;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:23,代碼來源:ListViewAutoScrollHelper.java

示例6: locateListViewItem

import android.widget.ListView; //導入方法依賴的package包/類
public static View locateListViewItem(ListView listView, ItemViewLocate locate, Object compareObj) {
    for (int i = 0; i < listView.getChildCount(); i++) {
        View child = listView.getChildAt(i);
        if (locate.locate(child, compareObj)) {
            return child;
        }
    }

    return null;
}
 
開發者ID:myl2ning,項目名稱:fragmentnav,代碼行數:11,代碼來源:Androids.java

示例7: getViewByPosition

import android.widget.ListView; //導入方法依賴的package包/類
private View getViewByPosition(int pos, ListView listView) {
    final int firstListItemPosition = listView.getFirstVisiblePosition();
    final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;

    if (pos < firstListItemPosition || pos > lastListItemPosition ) {
        return listView.getAdapter().getView(pos, null, listView);
    } else {
        final int childIndex = pos - firstListItemPosition;
        return listView.getChildAt(childIndex);
    }
}
 
開發者ID:Bartout-Team,項目名稱:Bartout,代碼行數:12,代碼來源:DrinkBeverageActivity.java

示例8: canListViewScrollUp

import android.widget.ListView; //導入方法依賴的package包/類
/**
 * Utility method to check whether a {@link ListView} can scroll up from it's current position.
 * Handles platform version differences, providing backwards compatible functionality where
 * needed.
 */
private static boolean canListViewScrollUp(ListView listView) {
    if (android.os.Build.VERSION.SDK_INT >= 14) {
        // For ICS and above we can call canScrollVertically() to determine this
        return ViewCompat.canScrollVertically(listView, -1);
    } else {
        // Pre-ICS we need to manually check the first visible item and the child view's top
        // value
        return listView.getChildCount() > 0 &&
                (listView.getFirstVisiblePosition() > 0
                        || listView.getChildAt(0).getTop() < listView.getPaddingTop());
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:SwipeRefreshListFragment.java

示例9: toBitmap

import android.widget.ListView; //導入方法依賴的package包/類
/**
 * 把view轉化為bitmap(截圖)
 * 參見:http://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 獲取listView實際高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 獲取scrollView實際高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截圖去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    if (!bitmap.isRecycled()) {
        LogUtils.verbose("recycle bitmap: " + bitmap.toString());
        bitmap.recycle();
    }
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:54,代碼來源:ConvertUtils.java

示例10: toBitmap

import android.widget.ListView; //導入方法依賴的package包/類
/**
 * 把view轉化為bitmap(截圖)
 * 參見:http://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 獲取listView實際高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 獲取scrollView實際高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截圖去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    if (!bitmap.isRecycled()) {
       // LogUtils.verbose("recycle bitmap: " + bitmap.toString());
        bitmap.recycle();
    }
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
開發者ID:ruiqiao2017,項目名稱:Renrentou,代碼行數:54,代碼來源:ConvertUtils.java

示例11: toBitmap

import android.widget.ListView; //導入方法依賴的package包/類
/**
 * convert View to Bitmap.
 *
 * @param view the view
 * @return the bitmap
 * @link http ://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    //以下代碼用於把當前view轉化為bitmap(截圖)
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 獲取listView實際高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 獲取scrollView實際高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截圖去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    cacheBitmap.recycle();
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
開發者ID:mainh,項目名稱:MainCalendar,代碼行數:55,代碼來源:ConvertUtils.java

示例12: testAdd

import android.widget.ListView; //導入方法依賴的package包/類
public void testAdd(){
    solo.waitForText("Unable to load moods from database");
    ListView listview = (ListView) solo.getView(R.id.profile_moodlist);

    int count = listview.getChildCount();

    solo.clickOnView(solo.getView(R.id.fab));

    solo.waitForActivity(AddMoodActivity.class);

    solo.clickOnView(solo.getView(R.id.action_add_complete));

    solo.waitForActivity(MyProfileActivity.class);
    solo.sleep(1000);

    assertEquals(count+1, listview.getChildCount());

    solo.setWiFiData(true);
    solo.sleep(2000);

    solo.clickInList(1);
    solo.goBack();

    solo.waitForText("Synchronization completed.");

    solo.setWiFiData(false);
}
 
開發者ID:CMPUT301W17T08,項目名稱:Moodr,代碼行數:28,代碼來源:OfflineTest.java

示例13: testDelete

import android.widget.ListView; //導入方法依賴的package包/類
public void testDelete(){

        ListView listview = (ListView) solo.getView(R.id.profile_moodlist);

        int count = listview.getChildCount();

        solo.clickInList(1,1);

        TextView textview = (TextView) solo.getView(R.id.viewMoodMood);
        String mood = textview.getText().toString();

        solo.waitForActivity(ViewMyMoodActivity.class);

        solo.clickOnView(solo.getView(R.id.delete_mood));

        solo.assertCurrentActivity("Wrong activity", MyProfileActivity.class);

        assertEquals(count-1, listview.getChildCount());

        solo.setWiFiData(true);
        solo.sleep(2000);

        solo.clickInList(1);
        solo.goBack();

        solo.waitForText("Synchronization completed.");

        solo.setWiFiData(false);

    }
 
開發者ID:CMPUT301W17T08,項目名稱:Moodr,代碼行數:31,代碼來源:OfflineTest.java


注:本文中的android.widget.ListView.getChildCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。