本文整理了Java中android.widget.Adapter.getView()
方法的一些代码示例,展示了Adapter.getView()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Adapter.getView()
方法的具体详情如下:
包路径:android.widget.Adapter
类名称:Adapter
方法名:getView
暂无
代码示例来源:origin: stackoverflow.com
/**
* Computes the widest view in an adapter, best used when you need to wrap_content on a ListView, please be careful
* and don't use it on an adapter that is extremely numerous in items or it will take a long time.
*
* @param context Some context
* @param adapter The adapter to process
* @return The pixel width of the widest View
*/
public static int getWidestView(Context context, Adapter adapter) {
int maxWidth = 0;
View view = null;
FrameLayout fakeParent = new FrameLayout(context);
for (int i=0, count=adapter.getCount(); i<count; i++) {
view = adapter.getView(i, view, fakeParent);
view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
int width = view.getMeasuredWidth();
if (width > maxWidth) {
maxWidth = width;
}
}
return maxWidth;
}
代码示例来源:origin: stackoverflow.com
public class HeaderAdapter{
private Adapter mAdapter; // this adapter is the adapter that you will normally have, for your listview
getViewTypeCount(){
return mAdapter.getViewTypeCount() + 1;
}
getView(int pos, View convertView){
// Handle only the first position, othervise, let mAdapter return
if (pos!=0) return mAdapter.getView(pos-1, convertView);
//
View v = LayoutInflater.inflate(R.layout.other_linear_layout);
// Bind the v if necessary
return v;
}
}
代码示例来源:origin: robolectric/robolectric
public int findIndexOfItemContainingText(String targetText) {
for (int i = 0; i < realAdapterView.getCount(); i++) {
View childView = realAdapterView.getAdapter().getView(i, null, new FrameLayout(realAdapterView.getContext()));
ShadowView shadowView = Shadow.extract(childView);
String innerText = shadowView.innerText();
if (innerText.contains(targetText)) {
return i;
}
}
return -1;
}
代码示例来源:origin: androidquery/androidquery
adapter.getView(drawPos, convertView, parent);
代码示例来源:origin: xiepeijie/SwipeCardView
private void layoutChildren(int startingIndex, int adapterCount){
while (startingIndex < Math.min(adapterCount, MAX_VISIBLE) ) {
View item = null;
if (cacheItems.size() > 0) {
item = cacheItems.get(0);
cacheItems.remove(item);
}
View newUnderChild = mAdapter.getView(startingIndex, item, this);
if (newUnderChild.getVisibility() != GONE) {
makeAndAddView(newUnderChild, startingIndex);
LAST_OBJECT_IN_STACK = startingIndex;
}
startingIndex++;
}
}
代码示例来源:origin: GeekGhost/Ghost
private void addNextCard() {
if (nextAdapterCard < mAdapter.getCount()) {
// TODO: Make view recycling work
// TODO: Instead of removing the view from here and adding it again when it's swiped
// ... don't remove and add to this instance: don't call removeView & addView in sequence.
View newBottomChild = mAdapter.getView(nextAdapterCard, null/*lastRemovedView*/, this);
if (hardwareAccelerationEnabled) {
//set backed by an off-screen buffer
newBottomChild.setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
//set the initial Y value so card appears from under the deck
//newBottomChild.setY(paddingTop);
addAndMeasureChild(newBottomChild);
nextAdapterCard++;
}
setupTopCard();
}
代码示例来源:origin: stackoverflow.com
&& getChildAt(childPosition) != null) {
Log.v(TAG, "Refreshing view (data=" + dataPosition + ",child=" + childPosition + ")");
mAdapter.getView(dataPosition, getChildAt(childPosition), this);
代码示例来源:origin: stackoverflow.com
Adapter ListAdapter = listview.getAdapter();
View mView = ListAdapter.getView(0, null, listview);
mView.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int requiredHeight = listview.getChildCount() * mView.getMeasuredHeight();
代码示例来源:origin: stackoverflow.com
public static int getItemViewHeight(Context context, Adapter adapter, int index) {
FrameLayout fakeParent = new FrameLayout(context);
View view = adapter.getView(index, null, fakeParent);
view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
return view.getMeasuredHeight();
}
代码示例来源:origin: stackoverflow.com
int dbRowId;
Adapter adapter = myListView.getAdapter();
View listViewRow = adapter.getView(selectedRow);
TextView dbRowView = (TextView) listViewRow.findViewById(R.id.rowid, null, null);
String dbRowAsString = dbRowView.getText().toString();
dbRowId = Integer.parseInt(dbRowAsString);
代码示例来源:origin: kochka/WeightLogger
private View makeAndAddView(int position, boolean addToEnd, View convertView) {
View view = mAdapter.getView(position, convertView, this);
if(view != convertView && convertView != null)
mRecycledViews.add(convertView);
return setupChild(view, addToEnd, view == convertView);
}
代码示例来源:origin: stackoverflow.com
LinearLayout container = (LinearLayout) findViewById(R.id.list_container);
Adapter listAdapter = createListAdapter();
final int childCount = listAdapter.getCount();
for (int i = 0; i < childCount; i++) {
View child = listAdapter.getView(i, null, container);
container.addView(child);
}
代码示例来源:origin: MiEcosystem/mijiaSDK
private View obtainView(int position) {
View convertView = getRecycledView();
View view = mAdapter.getView(position, convertView, this);
if(view != convertView && convertView != null)
mRecycledViews.add(convertView);
mLastObtainedViewWasRecycled = (view == convertView);
LayoutParams p = view.getLayoutParams();
if (p == null) {
p = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
view.setLayoutParams(p);
}
return view;
}
代码示例来源:origin: stackoverflow.com
// ListView myListView = the ListView in question
// int selectedRow = the currently selected row in the ListView
// Each row in the ListView is backed by an object of type MyCustomDataClass
int dbRowId;
Adapter adapter = myListView.getAdapter();
MyCustomDataClass data = (MyCustomDataClass) adapter.getItem(selectedRow);
dbRowId = data.getDatabaseRowId();
// OR
dbRowId = data.rowId;
// OR whatever method the object has for getting the ID.
// OR
View listViewRow = adapter.getView(selectedRow);
TextView dbRowView = (TextView) listViewRow.findViewById(R.id.rowid);
String dbRowAsString = dbRowView.getText().toString();
dbRowId = Integer.parseInt(dbRowAsString);
代码示例来源:origin: adamantoise/robocrosswords
public View getView(int i, View view, ViewGroup group) {
int sectionnum = 0;
for (Adapter adapter : this.sections) {
int size = adapter.getCount() + 1;
// check if position inside this section
if (i == 0) {
return headers.getView(sectionnum, view, group);
}
if (i < size) {
return adapter.getView(i - 1, view, group);
}
// otherwise jump into next section
i -= size;
sectionnum++;
}
return null;
}
代码示例来源:origin: QDqiaodong/Reader
private View getOrCreateChild(int i) {
LogUtils.d(TAG, "getOrCreateChild i==" + i);
View v = mChildViews.get(i);
if (v == null) {
v = mAdapter.getView(i, getCached(), this);
addAndMeasureChild(i, v);
onChildSetup(i, v);
}
return v;
}
代码示例来源:origin: org.robolectric/shadows-framework
public int findIndexOfItemContainingText(String targetText) {
for (int i = 0; i < realAdapterView.getCount(); i++) {
View childView = realAdapterView.getAdapter().getView(i, null, new FrameLayout(realAdapterView.getContext()));
ShadowView shadowView = Shadow.extract(childView);
String innerText = shadowView.innerText();
if (innerText.contains(targetText)) {
return i;
}
}
return -1;
}
代码示例来源:origin: org.robolectric/framework
public int findIndexOfItemContainingText(String targetText) {
for (int i = 0; i < realAdapterView.getCount(); i++) {
View childView = realAdapterView.getAdapter().getView(i, null, new FrameLayout(realAdapterView.getContext()));
String innerText = shadowOf(childView).innerText();
if (innerText.contains(targetText)) {
return i;
}
}
return -1;
}
代码示例来源:origin: org.robolectric/shadows-core
public int findIndexOfItemContainingText(String targetText) {
for (int i = 0; i < realAdapterView.getCount(); i++) {
View childView = realAdapterView.getAdapter().getView(i, null, new FrameLayout(realAdapterView.getContext()));
String innerText = shadowOf(childView).innerText();
if (innerText.contains(targetText)) {
return i;
}
}
return -1;
}
代码示例来源:origin: org.robolectric/shadows-core-v23
public int findIndexOfItemContainingText(String targetText) {
for (int i = 0; i < realAdapterView.getCount(); i++) {
View childView = realAdapterView.getAdapter().getView(i, null, new FrameLayout(realAdapterView.getContext()));
String innerText = shadowOf(childView).innerText();
if (innerText.contains(targetText)) {
return i;
}
}
return -1;
}
内容来源于网络,如有侵权,请联系作者删除!