use of android.widget.ListAdapter in project android-vertical-slide-view by xmuSistone.
the class VerticalFragment2 method initView.
/**
* 初始化ListView
*
* @param rootView
* 根View
*/
private void initView(View rootView) {
ListView listview = (ListView) rootView.findViewById(R.id.fragment2_listview);
ListAdapter adapter = new BaseAdapter() {
private LayoutInflater inflater;
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (inflater == null) {
inflater = LayoutInflater.from(getActivity());
}
if (null == convertView) {
convertView = inflater.inflate(R.layout.fragment2_list_item, null);
}
return convertView;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public int getCount() {
return 100;
}
};
listview.setAdapter(adapter);
}
use of android.widget.ListAdapter in project android_frameworks_base by ResurrectionRemix.
the class TransparentListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.gradient));
setContentView(R.layout.list_activity);
ListAdapter adapter = new SimpleListAdapter(this);
ListView list = (ListView) findViewById(R.id.list);
list.setAdapter(adapter);
list.setCacheColorHint(0);
list.setVerticalFadingEdgeEnabled(true);
registerForContextMenu(list);
}
use of android.widget.ListAdapter in project ride-read-android by Ride-Read.
the class ListViewMeasure method setListViewHeightBaseAdapter.
public static void setListViewHeightBaseAdapter(ListView listViewHeightBaseAdapter) {
ListAdapter adapter = listViewHeightBaseAdapter.getAdapter();
if (adapter == null) {
return;
}
int totalHeight = 0;
for (int i = 0; i < adapter.getCount(); i++) {
View listItem = adapter.getView(i, null, listViewHeightBaseAdapter);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listViewHeightBaseAdapter.getLayoutParams();
params.height = totalHeight + (listViewHeightBaseAdapter.getDividerHeight() * (adapter.getCount() - 1));
listViewHeightBaseAdapter.setLayoutParams(params);
}
use of android.widget.ListAdapter in project LshUtils by SenhLinsh.
the class ViewUtils method getListViewHeightBasedOnChildren.
/**
* 根据所有条目计算ListView的高
*/
public static int getListViewHeightBasedOnChildren(ListView view) {
int height = getAbsListViewHeightBasedOnChildren(view);
ListAdapter adapter;
int adapterCount;
if (view != null && (adapter = view.getAdapter()) != null && (adapterCount = adapter.getCount()) > 0) {
height += view.getDividerHeight() * (adapterCount - 1);
}
return height;
}
use of android.widget.ListAdapter in project android_frameworks_base by ResurrectionRemix.
the class ListFragment method ensureList.
private void ensureList() {
if (mList != null) {
return;
}
View root = getView();
if (root == null) {
throw new IllegalStateException("Content view not yet created");
}
if (root instanceof ListView) {
mList = (ListView) root;
} else {
mStandardEmptyView = (TextView) root.findViewById(com.android.internal.R.id.internalEmpty);
if (mStandardEmptyView == null) {
mEmptyView = root.findViewById(android.R.id.empty);
} else {
mStandardEmptyView.setVisibility(View.GONE);
}
mProgressContainer = root.findViewById(com.android.internal.R.id.progressContainer);
mListContainer = root.findViewById(com.android.internal.R.id.listContainer);
View rawListView = root.findViewById(android.R.id.list);
if (!(rawListView instanceof ListView)) {
throw new RuntimeException("Content has view with id attribute 'android.R.id.list' " + "that is not a ListView class");
}
mList = (ListView) rawListView;
if (mList == null) {
throw new RuntimeException("Your content must have a ListView whose id attribute is " + "'android.R.id.list'");
}
if (mEmptyView != null) {
mList.setEmptyView(mEmptyView);
} else if (mEmptyText != null) {
mStandardEmptyView.setText(mEmptyText);
mList.setEmptyView(mStandardEmptyView);
}
}
mListShown = true;
mList.setOnItemClickListener(mOnClickListener);
if (mAdapter != null) {
ListAdapter adapter = mAdapter;
mAdapter = null;
setListAdapter(adapter);
} else {
// have our data right away and start with the progress indicator.
if (mProgressContainer != null) {
setListShown(false, false);
}
}
mHandler.post(mRequestFocus);
}
Aggregations