我正在動態創建LinearLayout
。我需要刪除LinearLayout
上的LongPress
事件。在長按事件上刪除LinearLayout
我的代碼:
public void addTileView(View v) {
_parentLayout = (LinearLayout) findViewById(R.id.gridCont);
View child = getLayoutInflater().inflate(R.layout.customtileview,null);
((TextView)child.findViewById(R.id.tileText)).setText("Tile View :"+_tileViewCount++);
_parentLayout.addView(child);
_parentLayout.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Delete", Toast.LENGTH_SHORT).show();
return true;
}
});
}
如何做到這一點?
它將刪除父也。我需要刪除在哪個longpress事件觸發的指定視圖。 – tilak
child.removeAllViews()我不會沒有它會工作與否。去嘗試一下。我希望它會起作用 –