Android实现自动清空,android – 删除图像后自动刷新在gridview中不...
我正在研究網格視圖,我是android的新手.我之前在gridview中遇到了一個問題,我解決了自己發布鏈接,因為代碼與上下文任務中添加的新功能相同
i dont know how to get the position of the img that i click so i can pass it to next acitvity
剩下的代碼如下
@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();
}
我不允許發布圖像,因為我的聲譽較少但是當調用刪除功能時,圖像被刪除但網格視圖中有一個空白空間我希望在調用刪除功能后自動填充空白空間.
總結
以上是生活随笔為你收集整理的Android实现自动清空,android – 删除图像后自动刷新在gridview中不...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android drawableleft
- 下一篇: Android常用ui,XUI: 一个简