I actually figured out some way to do it
static final String TITLE = "title";
List<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
PopupWindow popupMessage;
ImageButton popupButton;
GridView gridview;
View view;
// Use this to add items to the list that the ListPopupWindow will use
private void addItem(String title) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put(TITLE, title);
data.add(map);
}
public void init() {
popupButton = (ImageButton) findViewById(R.id.menu_btn_btn);
view = LayoutInflater.from(this).inflate(R.layout.popup_window, null);
gridview = (GridView) view.findViewById(R.id.popup_window_gridview);
gridview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.e("clicked", "ok");
}
});
SimpleAdapter adapter = new SimpleAdapter(
this,
data,
android.R.layout.activity_list_item, // You may want to use your own cool layout
new String[]{TITLE}, // These are just the keys that the data uses
new int[]{android.R.id.text1}); // The view ids to map the data to
addItem("one");
addItem("two");
addItem("three");
addItem("four");
addItem("five");
addItem("six";
gridview.setAdapter(adapter);
}
public void popupInit() {
popupButton.setOnClickListener(this);
popupMessage = new PopupWindow(view, LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
popupMessage.setContentView(view);
}
after than all you have to is to init() and popupInit() in onCreate()
Unfortunately, the gridView onItemClickListner doesn't work actually and I still did not figured out why!