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


Java ListAdapter类代码示例

本文整理汇总了Java中android.widget.ListAdapter的典型用法代码示例。如果您正苦于以下问题:Java ListAdapter类的具体用法?Java ListAdapter怎么用?Java ListAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: resizeListView

import android.widget.ListAdapter; //导入依赖的package包/类
private void resizeListView(ListView listView, boolean isBottomList) {
    ListAdapter adapter = listView.getAdapter();
    int count = adapter.getCount();
    int itemsHeight = 0;
    // Your views have the same layout, so all of them have
    // the same height
    View oneChild = listView.getChildAt(0);
    if (oneChild == null) {
        return;
    }
    itemsHeight = oneChild.getHeight();
    // Resize your list view
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) listView.getLayoutParams();
    params.height = isBottomList ? itemsHeight * count + itemsHeight / 2 : itemsHeight * count;
    listView.setLayoutParams(params);
}
 
开发者ID:Adyen,项目名称:adyen-android,代码行数:17,代码来源:PaymentMethodSelectionFragment.java

示例2: onPostExecute

import android.widget.ListAdapter; //导入依赖的package包/类
@Override
protected void onPostExecute(Void result) {
    super.onPostExecute(result);
    // Dismiss the progress dialog
    if (pDialog.isShowing())
        pDialog.dismiss();

    // Sorting a-z
    Collections.sort(posList, new Comparator<HashMap< String,String >>() {

        @Override
        public int compare(HashMap<String, String> lhs,
                           HashMap<String, String> rhs) {
            return lhs.get("name").compareTo(rhs.get("name"));
        }
    });

    // Updating parsed JSON data into ListView
    ListAdapter adapter = new SimpleAdapter(
            MainActivity.this, posList,
            R.layout.list_daerah, new String[]{"name"}, new int[]{R.id.name});

    lv.setAdapter(adapter);
}
 
开发者ID:bachors,项目名称:Android-Kode-POS,代码行数:25,代码来源:MainActivity.java

示例3: testFollowingList

import android.widget.ListAdapter; //导入依赖的package包/类
/**
 * test to make sure all followed profiles show up in the list
 */
public void testFollowingList(){

    ListAdapter adapter = ((ListView)solo.getView(R.id.vfuProfilesList)).getAdapter();

    for (Profile followed : profile.getFollowing()){

        boolean found = false;
        for (int i = 0; i < adapter.getCount(); ++i){
            if (adapter.getItem(i).equals(followed)){
                found = true;
                break;
            }
        }

        assertTrue("profile not found in followed users listview", found);
    }
}
 
开发者ID:CMPUT301F17T15,项目名称:CIA,代码行数:21,代码来源:ViewFollowedUsersIntentTests.java

示例4: testFollowingEvents

import android.widget.ListAdapter; //导入依赖的package包/类
/**
 * test to make sure all followed profile's habit events show up in the list, and are in sorted order
 */
public void testFollowingEvents(){
    // switch to history view
    solo.clickOnView(solo.getView(R.id.vfuHistoryIcon));
    solo.sleep(600);

    ListAdapter adapter = ((ListView)solo.getView(R.id.vfuEventsList)).getAdapter();
    for (CompletedEventDisplay event : profile.getFollowedHabitHistory()){
        boolean found = false;
        for (int i = 0; i < adapter.getCount(); ++i) {
            if (adapter.getItem(i).equals(event)) {
                found = true;
                break;
            }
        }
        assertTrue("habit not found in followed user habits listview", found);
    }
}
 
开发者ID:CMPUT301F17T15,项目名称:CIA,代码行数:21,代码来源:ViewFollowedUsersIntentTests.java

示例5: setAdapter

import android.widget.ListAdapter; //导入依赖的package包/类
/**
 * For each DragSortListView Listener interface implemented by
 * <code>adapter</code>, this method calls the appropriate
 * set*Listener method with <code>adapter</code> as the argument.
 *
 * @param adapter The ListAdapter providing data to back
 *                DragSortListView.
 * @see ListView#setAdapter(ListAdapter)
 */
@Override
public void setAdapter(ListAdapter adapter) {
    if (adapter != null) {
        mAdapterWrapper = new AdapterWrapper(adapter);
        adapter.registerDataSetObserver(mObserver);

        if (adapter instanceof DropListener) {
            setDropListener((DropListener) adapter);
        }
        if (adapter instanceof DragListener) {
            setDragListener((DragListener) adapter);
        }
        if (adapter instanceof RemoveListener) {
            setRemoveListener((RemoveListener) adapter);
        }
    } else {
        mAdapterWrapper = null;
    }

    super.setAdapter(mAdapterWrapper);
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:31,代码来源:DragSortListView.java

示例6: measureHeight

import android.widget.ListAdapter; //导入依赖的package包/类
private int measureHeight(int measureSpec) {
	int mode = MeasureSpec.getMode(measureSpec);
	if (mode == MeasureSpec.AT_MOST) {
		return MeasureSpec.makeMeasureSpec(measureSpec, mode);
	} else if (mode == MeasureSpec.EXACTLY) {
		ListAdapter adapter = getAdapter();
		if (adapter == null) {
			measureSpec = 0;
		} else {
			int result = 0;
			for (int i = 0; i < adapter.getCount(); i++) {
				View contentView = adapter.getView(i, null, null);
				contentView.measure(0, 0);
				result += contentView.getMeasuredHeight();
			}
			measureSpec = result + getDividerHeight()
					* (adapter.getCount() - 1);
		}
	}

	return MeasureSpec.makeMeasureSpec(measureSpec, mode);
}
 
开发者ID:Louis19910615,项目名称:youkes_browser,代码行数:23,代码来源:SuperListView.java

示例7: setListViewHeightBasedOnChildren

import android.widget.ListAdapter; //导入依赖的package包/类
private void setListViewHeightBasedOnChildren(ListView listView)
   {
       ListAdapter listAdapter = listView.getAdapter();
       if (listAdapter == null)
{
           // pre-condition
           return;
       }

       int totalHeight = 0;
       for (int i = 0; i < listAdapter.getCount(); i++)
{
           View listItem = listAdapter.getView(i, null, listView);
           listItem.measure(0, 0);
           totalHeight += listItem.getMeasuredHeight();
       }

       ViewGroup.LayoutParams params = listView.getLayoutParams();
       params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
       listView.setLayoutParams(params);
   }
 
开发者ID:stytooldex,项目名称:pius1,代码行数:22,代码来源:MaterialDialog.java

示例8: addTouchables

import android.widget.ListAdapter; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void addTouchables(ArrayList<View> views) {
    final int count = getChildCount();
    final int firstPosition = mFirstPosition;
    final ListAdapter adapter = mAdapter;

    if (adapter == null) {
        return;
    }

    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (adapter.isEnabled(firstPosition + i)) {
            views.add(child);
        }
        child.addTouchables(views);
    }
}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:22,代码来源:PLA_AbsListView.java

示例9: onListingUpdate

import android.widget.ListAdapter; //导入依赖的package包/类
@Override
public void onListingUpdate(List<? extends MetaFile2> files) {

    Resources res = getResources();
    // Get the folders only
    mListItems = new ArrayList<Item>(files.size());
    for (MetaFile2 file : files) {
        Item item = new Item();
        item.mUri = file.getUri();
        if (file.isDirectory()) {
            item.mHolder = res.getDrawable(R.drawable.filetype_music_folder);
            item.mEnabled = true; // Only the folders are enabled
        } else {
            item.mHolder = res.getDrawable(R.drawable.filetype_generic2);
            item.mEnabled = false; // Only the folders are enabled
        }
        mListItems.add(item);
    }

    ListAdapter la = new FolderArrayAdapter(getActivity(), android.R.layout.simple_list_item_1);
    mListView.setAdapter(la);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:23,代码来源:FolderPicker.java

示例10: onPostExecute

import android.widget.ListAdapter; //导入依赖的package包/类
@Override
protected void onPostExecute(final List<AppInfo> results) {    
  ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity, 
                                                      R.layout.app_picker_list_item,
                                                      R.id.app_picker_list_item_label, 
                                                      results) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = super.getView(position, convertView, parent);
      Drawable icon = results.get(position).getIcon();
      if (icon != null) {
        ((ImageView) view.findViewById(R.id.app_picker_list_item_icon)).setImageDrawable(icon);
      }
      return view;
    }
  };
  activity.setListAdapter(listAdapter);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:19,代码来源:LoadPackagesAsyncTask.java

示例11: setListAdapter

import android.widget.ListAdapter; //导入依赖的package包/类
public void setListAdapter(ListAdapter adapter) {
    boolean z = false;
    boolean hadAdapter;
    if (this.mAdapter != null) {
        hadAdapter = true;
    } else {
        hadAdapter = false;
    }
    this.mAdapter = adapter;
    if (this.mList != null) {
        this.mList.setAdapter(adapter);
        if (!this.mListShown && !hadAdapter) {
            if (getView().getWindowToken() != null) {
                z = true;
            }
            setListShown(true, z);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:ListFragment.java

示例12: showNotificationDialogPRO

import android.widget.ListAdapter; //导入依赖的package包/类
public static void showNotificationDialogPRO(Activity activity){
    ArrayList<Bitmap> iconsBit = new ArrayList<>();

    for(Drawable d : MyNotificationListenerService.icons){
        iconsBit.add(Utils.convertDrawableToBitmap(d));
    }

    ListAdapter adapter = new ArrayAdapterWithIcon(activity, MyNotificationListenerService.names, iconsBit);

    new AlertDialog.Builder(activity).setTitle(MyNotificationListenerService.TITLE)
            .setAdapter(adapter, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {

                }
            }).show();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:17,代码来源:Utilities.java

示例13: showIconInPack

import android.widget.ListAdapter; //导入依赖的package包/类
private static void showIconInPack(final Activity activity, String packName, final ShortcutInfo shortcutInfo){

        String packNamePackage = null;
        for (AppInfo app : AllAppsList.data) {
            if(app.title.equals(packName)){
                packNamePackage = app.getTargetComponent().getPackageName();
            }
        }

        items.clear();
        icons.clear();
        final HashMap<String, Bitmap> map = new HashMap<>(getIconPack(packNamePackage));

        ListAdapter adapter = new ArrayAdapterWithIcon(activity, items, icons);

        new AlertDialog.Builder(activity).setTitle(activity.getString(R.string.alert_choose_app))
                .setAdapter(adapter, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {
                        saveBitmapPref(activity, shortcutInfo.getTargetComponent().getPackageName(), icons.get(item));
                        //Launcher.getLauncherAppState().reloadWorkspace();
                    }
                }).show();
    }
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:24,代码来源:Utilities.java

示例14: setListViewHeightBasedOnChildren

import android.widget.ListAdapter; //导入依赖的package包/类
/**
 * @author sunglasses
 * @param listView
 * @category 计算listview高度
 */
public static void setListViewHeightBasedOnChildren(ListView listView) {
	ListAdapter listAdapter = listView.getAdapter();
	if (listAdapter == null) {
		return;
	}

	int totalHeight = 0;
	for (int i = 0; i < listAdapter.getCount(); i++) {
		View listItem = listAdapter.getView(i, null, listView);
		listItem.measure(0, 0);
		totalHeight += listItem.getMeasuredHeight();
	}

	ViewGroup.LayoutParams params = listView.getLayoutParams();
	params.height = totalHeight
			+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));
	listView.setLayoutParams(params);
}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:24,代码来源:Tools.java

示例15: onPostExecute

import android.widget.ListAdapter; //导入依赖的package包/类
@Override
protected void onPostExecute(final List<AppInfo> results) {
    ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity,
            R.layout.app_picker_list_item,
            R.id.app_picker_list_item_label,
            results) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = super.getView(position, convertView, parent);
            Drawable icon = results.get(position).getIcon();
            if (icon != null) {
                ((ImageView) view.findViewById(R.id.app_picker_list_item_icon)).setImageDrawable(icon);
            }
            return view;
        }
    };
    activity.setListAdapter(listAdapter);
}
 
开发者ID:xiong-it,项目名称:ZXingAndroidExt,代码行数:19,代码来源:LoadPackagesAsyncTask.java


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