1

I wanted to create a context menu in my app. But its difficult without ListActivity. I have a FragmantActivity with a ViewPager, and the ViewPager's adapter contains a few views which extend LinearLayout. Those LinearLayout views contain a list view.

So how can I create a ContextMenu in a class which extends LinearLayout ?

so here is the class i mentiond, i cleared the code, just showing the listview which i wanted to have a context menu

public class Days extends LinearLayout {

public Days(Context context, AttributeSet attrs, String day) {
    super(context, attrs);
    init(day);
}
public Days(Context context, String day) {
    super(context);
    init(day);
}
private void init(String day) {
    final ListView lv = new ListView(getContext());
    lv.setPadding(0, 5, 0, 5);
    Adapter adapter = new CustomListviewAdapter(getContext(), orak);
    ((BaseAdapter) adapter).notifyDataSetChanged();
    lv.setAdapter((ListAdapter) adapter);   
    LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.FILL_PARENT);

addView(lv, params);
}

and here is the viewpager adapter class where i add this layout

private class MyPagerAdapter extends PagerAdapter {

    private ArrayList<LinearLayout> views;

    public MyPagerAdapter(Context context) {
        views = new ArrayList<LinearLayout>();
        views.add(new Days(context, "Monday"));
                     ......... etc..

    }

and this viewpager is in a simple activity

If anyone knows the answer, please help.

executioner
  • 117
  • 2
  • 4
  • 16

1 Answers1

0

What's the link between listActivity and context menus ? Can't you just register your view for context menus as explained here ?

Community
  • 1
  • 1
Snicolas
  • 37,840
  • 15
  • 114
  • 173