当前位置: 首页>>代码示例>>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;未经允许,请勿转载。