本文整理了Java中android.widget.GridView.getItemAtPosition()
方法的一些代码示例,展示了GridView.getItemAtPosition()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.getItemAtPosition()
方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:getItemAtPosition
暂无
代码示例来源:origin: stackoverflow.com
public class MainActivity extends Activity {
private TextView text;
private GridView gridView;
private final String[] items = new String[]{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sample_activity);
text = (TextView) findViewById(R.id.feedback);
gridView = (GridView) this.findViewById(R.id.myGridView);
CustomGridAdapter gridAdapter = new CustomGridAdapter(MainActivity.this, items);
gridView.setAdapter(gridAdapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
text.setText((String) (gridView.getItemAtPosition(position)));
Log.i("ITEM_CLICKED", "" + (String) (gridView.getItemAtPosition(position)));
}
});
}
}
代码示例来源:origin: fasteque/rgb-tool
private void deleteSelectedItems() {
SparseBooleanArray checked = mGridView.getCheckedItemPositions();
ArrayList<Integer> positions = new ArrayList<>();
for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) {
positions.add(checked.keyAt(i));
}
}
Collections.sort(positions, Collections.reverseOrder());
for (int position : positions) {
Cursor cursor = (Cursor) mGridView.getItemAtPosition(position);
if (cursor != null) {
String photoPath = cursor.getString(cursor.getColumnIndex("_data"));
File existingFile = new File(photoPath);
//noinspection ResultOfMethodCallIgnored
existingFile.delete();
getContentResolver().delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, MediaStore.Images.Media.DATA
+ "=?", new String[]{photoPath});
}
mAdapter.notifyDataSetChanged();
}
}
代码示例来源:origin: OceanLabs/Android-Print-SDK
/*****************************************************
*
* Called when an item is clicked.
*
*****************************************************/
@Override
public void onItemClick( AdapterView<?> parent, View view, int position, long id )
{
if ( mImageSourceGridView != null && parent == mImageSourceGridView )
{
///// Image Source /////
AImageSource imageSource = (AImageSource)mImageSourceGridView.getItemAtPosition( position );
imageSource.onPick( this, getTotalImagesUsedCount(), mProduct.hasMultiplePackSupport(), mProduct.getQuantityPerSheet(), position );
}
}
代码示例来源:origin: OceanLabs/Android-Print-SDK
/*****************************************************
*
* Called when an item is clicked.
*
*****************************************************/
@Override
public void onItemClick( AdapterView<?> parent, View view, int position, long id )
{
if ( parent == mImageSourceGridView )
{
AImageSource imageSource = (AImageSource)mImageSourceGridView.getItemAtPosition( position );
imageSource.onPick( this, mProduct.getUserJourneyType().usesSingleImage(),
mProduct.hasMultiplePackSupport(), mProduct.getQuantityPerSheet(), position );
}
}
内容来源于网络,如有侵权,请联系作者删除!