Make a TableRow deletable
How can I make a View can be deleted after a longClick. In my case, I'm trying to make this with a TableRow. How can I do that wh开发者_如何转开发ite border with a red circle?
I'm not sure what the question about the white border/red circle is about but here is a good direction to delete a tableRow after long-clicking on it.
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo){
TableLayout yourTable = (TableLayout) findViewById(R.id.yourTableId);
TableRow yourTableRow = yourTable.getChildAt(INDEX_OF_YOUR_ROW_IN_THE_TABLE);
if(v.getId() == yourTableRow.getId()){
yourTable.removeView(yourTableRow);
}
}
This should work if you know the index of the row you're trying to click on and your TableRow has an ID.
This post solved my problem: Turn Views Editable on Android
精彩评论