我在网格视图上工作,并且我是android.I中的新成员之前在gridview中遇到了一个问题,我解决了自己我发布链接,因为代码与新的在上下文任务附加功能 i dont know how to get the position of the img that i click so i can pass it to next acitvity 剩下的代码如下删除图像后自动刷新不能在gridview中工作
@Override
public boolean onContextItemSelected(MenuItem item) {
if(item.getTitle()=="View"){function1(item.getItemId());}
else if(item.getTitle()=="Details"){function2(item.getItemId());}
else if(item.getTitle()=="Delete"){function3(item.getItemId());}
else {return false;}
return true;
}
public void function1(int id){
//String prompt;
// Sending image id to FullScreenActivity
/*Toast.makeText(getApplicationContext(),
path,
Toast.LENGTH_LONG).show();*/
Intent i = new Intent(getApplicationContext(), FullImageActivity.class);
i.putExtra("id", path);
startActivity(i);
}
public void function2(int id){
Toast.makeText(this, "Details func called", Toast.LENGTH_SHORT).show();
}
public void function3(int id){
File file = new File(path);
if(file.exists())
{
boolean deleted = file.delete();
}
myImageAdapter.notifyDataSetChanged();
//adapter.notifyDataSetChanged();
//gv.invalidateViews();
Toast.makeText(this, "function delete called", Toast.LENGTH_SHORT).show();
}
我不允许张贴图片,因为我有较少的声誉,但是当删除func被称为图像被删除,但有一个空的空间在网格视图中,我希望在调用delete func后自动填充空白空间。
需要适配器再次绑定... – itsrajesh4uguys 2013-05-05 08:56:48
我不知道我怎么可以绑定在功能上3适配器好心告诉代码或任何链接将是有益的 – user2350640 2013-05-05 19:33:25