本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}