本文整理汇总了Java中android.widget.Adapter.getItem方法的典型用法代码示例。如果您正苦于以下问题:Java Adapter.getItem方法的具体用法?Java Adapter.getItem怎么用?Java Adapter.getItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Adapter
的用法示例。
在下文中一共展示了Adapter.getItem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getItem
import android.widget.Adapter; //导入方法依赖的package包/类
@Override
public Object getItem(int position)
{
for (final Map.Entry<String,Adapter> entry : sectionMap.entrySet())
{
final Adapter adapter = entry.getValue();
final int size = adapter.getCount() + (hasSectionHeader ? 1 : 0);
if (position == 0 && hasSectionHeader)
return entry.getKey();
if (position < size)
return adapter.getItem(position - 1);
position -= size;
}
return null;
}
示例2: updateNote
import android.widget.Adapter; //导入方法依赖的package包/类
private void updateNote(){
Adapter a = lvItemList.getAdapter();
JSONArray jsonArray = new JSONArray();
try {
CheckListItem temp;
for (int i = 0; i < itemNamesList.size(); i++) {
temp = (CheckListItem) a.getItem(i);
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", temp.getName());
jsonObject.put("checked", temp.isChecked());
jsonArray.put(jsonObject);
}
fillNameIfEmpty();
DbAccess.updateNote(getBaseContext(), id, etName.getText().toString(), jsonArray.toString(), currentCat);
Toast.makeText(getApplicationContext(), R.string.toast_updated, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: saveNote
import android.widget.Adapter; //导入方法依赖的package包/类
private void saveNote(){
Adapter a = lvItemList.getAdapter();
JSONArray jsonArray = new JSONArray();
try {
CheckListItem temp;
for (int i = 0; i < itemNamesList.size(); i++) {
temp = (CheckListItem) a.getItem(i);
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", temp.getName());
jsonObject.put("checked", temp.isChecked());
jsonArray.put(jsonObject);
}
fillNameIfEmpty();
id = DbAccess.addNote(getBaseContext(), etName.getText().toString(), jsonArray.toString(), DbContract.NoteEntry.TYPE_CHECKLIST, currentCat);
Toast.makeText(getApplicationContext(), R.string.toast_saved, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: getSelectedItem
import android.widget.Adapter; //导入方法依赖的package包/类
public Object getSelectedItem() {
if (mCurrSelectedView != null) {
int position = mCurrSelectedView.getPosition();
Adapter adapter = mSpinnerListView.getAdapter();
if (adapter != null && adapter.getCount() > 0 && position >= 0) {
return adapter.getItem(position);
} else {
return null;
}
}
return null;
}
示例5: getItemPosition
import android.widget.Adapter; //导入方法依赖的package包/类
public int getItemPosition(Object item) {
if (item == null)
return -1;
Adapter adapter = mSpinnerListView.getAdapter();
if (adapter != null) {
for (int i = 0; i < adapter.getCount(); i++) {
Object adpItem = adapter.getItem(i);
if (adpItem != null && adpItem.equals(item)) {
return i;
}
}
}
return -1;
}
示例6: getSelectedItem
import android.widget.Adapter; //导入方法依赖的package包/类
public Object getSelectedItem() {
Adapter localAdapter = getAdapter();
int i = getSelectedItemPosition();
if ((localAdapter != null) && (localAdapter.getCount() > 0) && (i >= 0))
return localAdapter.getItem(i);
return null;
}
示例7: getItem
import android.widget.Adapter; //导入方法依赖的package包/类
@Override
public Object getItem(int position) {
for (Object section : this.sections.keySet()) {
Adapter adapter = sections.get(section);
int size = adapter.getCount() + 1;
// check if position inside this section
if (position == 0) return section;
if (position < size) return adapter.getItem(position - 1);
// otherwise jump into next section
position -= size;
}
return null;
}
示例8: getContentString
import android.widget.Adapter; //导入方法依赖的package包/类
private String getContentString(){
StringBuilder content = new StringBuilder();
Adapter a = lvItemList.getAdapter();
CheckListItem temp;
for (int i=0; i < itemNamesList.size(); i++) {
temp = (CheckListItem) a.getItem(i);
content.append("- " + temp.getName() + " [" + (temp.isChecked() ? "✓" : " ") + "]\n");
}
return content.toString();
}
示例9: getItem
import android.widget.Adapter; //导入方法依赖的package包/类
public Object getItem(int position) {
for(Object section : this.sections.keySet()) {
Adapter adapter = sections.get(section);
int size = adapter.getCount() + 1;
// check if position inside this section
if(position == 0) return section;
if(position < size) return adapter.getItem(position - 1);
// otherwise jump into next section
position -= size;
}
return null;
}
示例10: getItemAtPosition
import android.widget.Adapter; //导入方法依赖的package包/类
public Object getItemAtPosition(int paramInt) {
Adapter localAdapter = getAdapter();
return (localAdapter == null) || (paramInt < 0) ? null : localAdapter.getItem(paramInt);
}