Hi I'm trying to put a string(class prices) in a context menu. But my code is not returning as I expected. Can someone help me to solve this?
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle(getString(R.string.display_title));
//menu.add(0, v.getId(), 0, getString(R.string.display_schedule_ticket_prices));
StringBuilder pricesAlert = new StringBuilder("");
//int i = 0;
for(float price: rates.getPrices()){
for (int j = 0; j < 3; j++){
pricesAlert.append(getString(R.string.display_schedule_train_class) + j + getString(R.string.display_schedule_train_rs) + price +"\r\n");
menu.add(pricesAlert);
}
}
}
Edited:
I'm getting the results something like this using above code.
But I want the output like this:
Here is a snippet
Is this what you want to do? refer http://www.stealthcopter.com/blog/2010/04/android-context-menu-example-on-long-press-gridview/
have you added actions to your context menu?