Like title, here is this problem in my activity like this:
An more button in every row of listview item .
When I click this more button then show activity context menu.
So I try to click button, but open context menu is the Adaper's context menu. My
Adapter
is extends fromBaseAdapter
, BaseAdapter
has not context menu.
My solution like example :
<ImageButton
android:id="@+id/more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:background="#00000000"
android:src="@drawable/btn_addressbook_more"
android:onClick="onMoreClick"/>
Add an event named
onMoreClick
, when user click this button will do onClick
event in activity
.
// maybe you can register a contextMenu for one item first
public void onMoreClick(View view) {
this.openContextMenu(view);
// when you read source code , you can find a very easy way to call openContextMenu like this : view.showContextMenu();
}
Add event impl to
Activity
, when click event happened open Activity's context menu. And execute flow code you will override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
// TODO you code for create context menu here
}
now you click more button, open an activity's context menu. but my item index is disappeared. You can do like me, set a
View Tag
to your button. here you can get Tag to get index.v.getTag(); // after you set Tag in Adapter's get view function.
So, that is! happy new year :)
slot siteleri
回复删除kralbet
tipobet
mobil ödeme bahis
betmatik
kibris bahis siteleri
poker siteleri
bonus veren siteler
betpark
7WQ
شركة تنظيف بالقصيم 9cZ6KVeWGP
回复删除شركة تنظيف شقق بالخبر k0REkux2bj
回复删除