How do I make it possible for a popup to come up, based upon the selection a user makes in a grid view?
I've got a ListView object, with a GridView within it, where I'll be putting data. The list view is in SingleMode. I want it so that the user can select a row, and based upon criteria in that row, it would then bring up a pop开发者_运维知识库up display relevant data to the selected row.
There are 2 possible ways I envision this could happen. I could put a button somewhere in the row (at this point I don't know how, but I'm sure it can be done), so that if the user clicks on the button, then my code would determine what it needs to from that client, to bring up the popup and display the additional data.
The second way I can envision this happening is I could make one of the columns a hyperlink field, still showing the data that column has to show for that row. When the user clicks on the hyperlink, then it would bring up the same popup that I discribed for the first scenario. However, again, I don't know how to do this.
So the question is, which is the "correct" or "more common" way of doing it, and how is it done?
You could use a toast. It will pop up in the middle of the screen and then you can mak
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(HelloGridView.this, "DATA YOU WANT TO DISPLAY", Toast.LENGTH_SHORT).show();
}
});
I'd advise writing a method that gets the data for that grid position and displays it. So in place of "DATA YOU WANT TO DISPLAY" you could call a method that returns a string with the data you want to display.
精彩评论