Leem.fin
Leem.fin

Reputation: 42592

PopupMenu in Android 2.1 API 7

I am developing Android 2.1 API 7 app. I am also using ActionbarSherlock library to implement Action Bar.

Now, I need to implement PopupMenu which is only support by API 11+.

How can I implement PopupMenu in Android 2.1 API 7 ?

Upvotes: 14

Views: 7078

Answers (5)

Ligboy
Ligboy

Reputation: 126

use the Android Support V7 Library;
android.support.v7.widget.PopupMenu

Upvotes: 4

kurryt
kurryt

Reputation: 210

You can create a ListDialogFragment which extends the SherlockDialogFragment and create your own Listener interface so you can handle selection events.

public class ListDialogFragment extends SherlockDialogFragment {

private String[] mValues;

public interface ListDialogListener {
    void onFinishListDialog(int selectedIndex, String tag);
}

private ListDialogFragment(String[] values) {
    mValues = values;
}

public static ListDialogFragment newInstance(int index, String[] values) {
    ListDialogFragment fragment = new ListDialogFragment(values);

    // Supply index input as an argument.
    Bundle args = new Bundle();
    args.putInt("index", index);
    fragment.setArguments(args);

    return fragment;
}

public int getSelectedIndex() {
    return getArguments().getInt("index", 0);
}

}

Upvotes: 0

taha
taha

Reputation: 771

you can use HoloEveryWhere, it bringing Holo theme from android 4.1 to 2.1 and above.

Upvotes: 1

user2771923
user2771923

Reputation:

Its Possible Import That Particular API files in your code , I think eclipse will do it for you , Just write code and if not imported than google it to import API.

Upvotes: 0

Alex
Alex

Reputation: 1416

I'v stucked with such a problem, and the only solution i'v found for myself was to use a list dialog in android sdk<11 and ListPopup in android 11 and higher.

Upvotes: 1

Related Questions