GridView适配器ImageView从布局创建.所有图像都是从URLs数据库item IDs中下载的,其中ID来自a JSONArray.让我们说,视图现在显示的项目
ID: 1,3,4,7.由于GridView项是动态的,因此位置(从0开始)无法在GridView上真正识别我的项目.有没有其他方法可以从数据库项ID中识别该图像?
public OnItemClickListener ClickListner = new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//Toast.makeText(getApplicationContext(),
// ""+position, Toast.LENGTH_SHORT).show();
//Identification code for the item to be added here
Intent view =
new Intent(main.this, View.class);
view.putExtra("ID", id);
//expected to have an ID equal to database item ID
startActivity(view);
}
};
Run Code Online (Sandbox Code Playgroud)