Java 类android.view.View.OnCreateContextMenuListener 实例源码

项目:laposte-android    文件:_HoloActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View view,
        ContextMenuInfo menuInfo) {
    final android.view.ContextMenu nativeMenu;
    if (menu instanceof ContextMenuWrapper) {
        nativeMenu = ((ContextMenuWrapper) menu).unwrap();
        super.onCreateContextMenu(nativeMenu, view, menuInfo);
        if (view instanceof ContextMenuCallbackGetter) {
            final OnCreateContextMenuListener l = ((ContextMenuCallbackGetter) view)
                    .getOnCreateContextMenuListener();
            if (l != null) {
                l.onCreateContextMenu(nativeMenu, view, menuInfo);
            }
        }
    }
}
项目:PBMS    文件:BookListActivity.java   
private void initListView() {
    listView.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v,
                ContextMenuInfo menuInfo) {
            menu.setHeaderTitle("选择操作");
            menu.add(0, 0, 0, "修改");
            menu.add(0, 1, 1, "删除");
        }
    });

    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int index,
                long itemId) {
        }
    });
}
项目:TflTravelAlerts    文件:_HoloActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View view,
        ContextMenuInfo menuInfo) {
    final android.view.ContextMenu nativeMenu;
    if (menu instanceof ContextMenuWrapper) {
        nativeMenu = ((ContextMenuWrapper) menu).unwrap();
        super.onCreateContextMenu(nativeMenu, view, menuInfo);
        if (view instanceof ContextMenuCallbackGetter) {
            final OnCreateContextMenuListener l = ((ContextMenuCallbackGetter) view)
                    .getOnCreateContextMenuListener();
            if (l != null) {
                l.onCreateContextMenu(nativeMenu, view, menuInfo);
            }
        }
    }
}
项目:Huochexing12306    文件:MonitorMangAty.java   
private void setListViewContextMenuWithDel() {
    lvMang.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v,
                ContextMenuInfo menuInfo) {
            intCurrDataPos = ((AdapterContextMenuInfo) menuInfo).position;
            menu.add(0, 0, 0, "删除");
        }
    });
}
项目:Huochexing12306    文件:MonitorMangAty.java   
private void setListViewContextMenuWithDel_Resume() {
    lvMang.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v,
                ContextMenuInfo menuInfo) {
            intCurrDataPos = ((AdapterContextMenuInfo) menuInfo).position;
            menu.add(0, 0, 0, "删除");
            menu.add(0, 1, 1, "恢复所有已暂停车次");
        }
    });
}
项目:gloomy-dungeons-2    文件:_HoloActivity.java   
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);
    if (view instanceof ContextMenuCallbackGetter) {
        final OnCreateContextMenuListener l = ((ContextMenuCallbackGetter) view)
                .getOnCreateContextMenuListener();
        if (l != null) {
            l.onCreateContextMenu(menu, view, menuInfo);
        }
    }
}
项目:coolreader    文件:BookshelfActivity.java   
public void init()   
{
    resolver = getContentResolver();
    bookList = DbDataOperation.getBookInfo(resolver);

    lvBookshelf = (ListView)findViewById(R.id.lvBookshelf);
    fileBrowser = (FileBrowser)findViewById(R.id.filebrowser);
    fileBrowser.setOnFileBrowserListener(this);
    lvBookshelf.setOnItemClickListener(this);
    ll=(RelativeLayout)findViewById(R.id.content);

    adapter = new CustomAdapter();
    lvBookshelf.setAdapter(adapter);
    lvBookshelf.setOnCreateContextMenuListener(new OnCreateContextMenuListener()
    {
        public void onCreateContextMenu(ContextMenu menu, View v,
                ContextMenuInfo menuInfo)
        {
            AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
            bookPosition = info.position;
            menu.add(Menu.NONE,R.id.menu_open,0,"打开");
            menu.add(Menu.NONE, R.id.menu_del, 1, "删除 " ); 
            menu.add(Menu.NONE, R.id.menu_des, 1, "详细 " ); 
        }
    });
       titleTextV=(TextView)findViewById(R.id.profile_header_title);
       titleTextV.setText("本地文件");
       backImageV=(ImageView)findViewById(R.id.profile_header_back);
       backImageV.setOnClickListener(new OnClickListener(){

               public void onClick(View arg0) {
                   // TODO Auto-generated method stub
                   ll.setVisibility(View.INVISIBLE);
               }

           });
}
项目:coolreader    文件:BookmarkActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    lvBookMark = getListView();
    resolver = getContentResolver();
    bookMarks = DbDataOperation.getBookMark(resolver);
    lvBookMark.setBackgroundResource(R.drawable.bg_listview);
    lvBookMark.setAdapter(adapter);
    lvBookMark.setDivider(null);
    lvBookMark.setCacheColorHint(000000);
    lvBookMark.setOnItemClickListener(new OnItemClickListener()
    {
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id)
        {
            currentPosition = position;
            intentToRead();
        }
    });
    lvBookMark.setOnCreateContextMenuListener(new OnCreateContextMenuListener()
    {
        public void onCreateContextMenu(ContextMenu menu, View v,
                ContextMenuInfo menuInfo)
        {
            AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
            currentPosition = info.position;
            menu.add(Menu.NONE,R.id.menu_open,0,"打开");
            menu.add(Menu.NONE, R.id.menu_del, 1, "删除 " ); 
            menu.add(Menu.NONE, R.id.menu_des, 1, "详细 " ); 

        }
    });
}
项目:dobroreader-mod    文件:DobroNewPostActivity.java   
private void addImage(String uri, boolean temporary, String rating) {
        if (attachments.size() >= 5)
            return;
        AsyncImageView image = new AsyncImageView(this);
        image.setScaleType(ScaleType.CENTER_INSIDE);
        Bitmap b = loadBitmap(uri);
        if(b == null)
            return;
        image.setImageBitmap(b);
        image.setTag(attachments.size());
        image.setAdjustViewBounds(true);
        image.setPadding(4, 2, 4, 2);
        registerForContextMenu(image);
        image.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
            @Override
            public void onCreateContextMenu(ContextMenu menu, View v,
                    ContextMenuInfo menuInfo) {
//              menu.setHeaderTitle("Select rating");
                int i;
                for (i = 0; i < ratings.length; i++) {
                    menu.add(Menu.NONE, (Integer) v.getTag(), i, ratings[i]);
                }
                menu.add(Menu.NONE, (Integer) v.getTag(), i++, R.string.crop);
                menu.add(Menu.NONE, (Integer) v.getTag(), i++, R.string.resize);
                menu.add(Menu.NONE, (Integer) v.getTag(), i++, R.string.delete);
            }
        });
        LinearLayout scroll = (LinearLayout) findViewById(R.id.picsScroll);
        scroll.addView(image);
        NewPostAttachment at = new NewPostAttachment(uri, rating);
        at.setImageView(image);
        if (temporary)
            at.delete_after = true;
        attachments.add(at);
    }
项目:stynico    文件:HCActivity.java   
/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.hc);
    StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
    toolbar = (android.support.v7.widget.Toolbar)
        findViewById(R.id.toolbar);
//      初始化Toolbar控件
    setSupportActionBar(toolbar);
//      用Toolbar取代ActionBar
    //toolbar.setTitleTextColor(getResources().getColor(R.color.text_font_white));//标题颜色
    //  toolbar.setSubtitleTextColor(getResources().getColor(R.color.text_font_white));//副标题颜色


//      设置导航按钮监听
    //overridePendingTransition(R.anim.out_to_right, R.anim.in_from_left);
    bn_add = (Button)findViewById(R.id.bn_add);
    bn_clear = (Button)findViewById(R.id.bn_clear);
    bn_hc = (Button)findViewById(R.id.bn_hc);
    list = (GridView)findViewById(R.id.list);

    bn_add.setOnClickListener(this);
    bn_clear.setOnClickListener(this);
    bn_hc.setOnClickListener(this);
    IntentFilter intentFilter=new IntentFilter();
    intentFilter.addAction(THIS_ACTION);
    registerReceiver(br, intentFilter);
    //FileList.curpath = "/mnt/sdcard";
    FileList.curpath = Environment.getExternalStorageDirectory().getAbsolutePath();
    FileList.broadcastAction = THIS_ACTION;
    initAdapter();
    formatter = new SimpleDateFormat("yyyy-MM-dd HH_mm_ss"); 
    //广告初始化

    sp = PreferenceManager.getDefaultSharedPreferences(this);
    list.setOnCreateContextMenuListener(new OnCreateContextMenuListener(){
        @Override
        public void onCreateContextMenu(ContextMenu p1, View p2, ContextMenu.ContextMenuInfo p3)
        {
            // TODO: Implement this method
            //p1.setHeaderTitle("选项");
            //第二个参数是id
            p1.add(0, 0, 0, "设置持续时间");
            p1.add(0, 1, 0, "移除该图片");

        }
        });
    }
项目:stynico    文件:FJActivity.java   
/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    setContentView(R.layout.fj);
    StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
    toolbar = (android.support.v7.widget.Toolbar)
        findViewById(R.id.toolbar);
//      初始化Toolbar控件
    setSupportActionBar(toolbar);
//      用Toolbar取代ActionBar
    //toolbar.setTitleTextColor(getResources().getColor(R.color.text_font_white));//标题颜色
    //toolbar.setSubtitleTextColor(getResources().getColor(R.color.text_font_white));//副标题颜色



//      设置导航按钮监听
    //overridePendingTransition(R.anim.out_to_right, R.anim.in_from_left);
    bn_add = (Button)findViewById(R.id.bn_add2);
    bn_clear = (Button)findViewById(R.id.bn_clear2);
    bn_hc = (Button)findViewById(R.id.bn_fj);
    list = (ListView)findViewById(R.id.list2);

    bn_add.setOnClickListener(this);
    bn_clear.setOnClickListener(this);
    bn_hc.setOnClickListener(this);
    IntentFilter intentFilter=new IntentFilter();
    intentFilter.addAction(THIS_ACTION);
    registerReceiver(br, intentFilter);
    FileList.curpath = Environment.getExternalStorageDirectory().getAbsolutePath();
    //FileList.filter = ".*.gif$";
    FileList.broadcastAction = THIS_ACTION;
    initAdapter();
    sp = PreferenceManager.getDefaultSharedPreferences(this);

    list.setOnCreateContextMenuListener(new OnCreateContextMenuListener(){
        @Override
        public void onCreateContextMenu(ContextMenu p1, View p2, ContextMenu.ContextMenuInfo p3)
        {
            // TODO: Implement this method
            p1.add(0, 0, 0, "移除该图片");
        }
        });
    }
项目:Huochexing12306    文件:A6OrderExpandableAdapter.java   
@Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
            ViewGroup parent) {
        if (mLstDatas == null || mLstDatas.size() == 0){
            return null;
        }
        final int groupPos = groupPosition;
        ChildViewHolder holder;
        if (convertView != null){
            holder = (ChildViewHolder) convertView.getTag();
        }else{
            convertView = mInflater.inflate(R.layout.item_a6_order, null);
            holder = new ChildViewHolder();
            holder.slv1 = (SubListView)convertView.findViewById(R.id.item_a6_order_slv1);
            convertView.setTag(holder);
        }
        holder.slv1.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

            @Override
            public void onCreateContextMenu(ContextMenu menu, View v,
                    ContextMenuInfo menuInfo) {
                mCurrGroupPos = groupPos;
                mCurrChildItemPos = ((AdapterContextMenuInfo) menuInfo).position;
                menu.clear();
                menu.add(A6OrderAty.CONTEXT_GROUP_0, A6OrderAty.CONTEXT_ITEM_ADD_TRAIN_INFO, 0, "添加车次");
                TicketInfo tInfo = mLstDatas.get(groupPos).getTickets().get(mCurrChildItemPos);
                try {
                    Date trainDate = TimeUtil.getDTFormat().parse(tInfo.getStart_train_date_page());
                    if (trainDate.getTime() >= (new Date()).getTime()){
                        if (tInfo.getReturn_flag().equals("Y")){
                            //退票
                            menu.add(A6OrderAty.CONTEXT_GROUP_0, A6OrderAty.CONTEXT_ITEM_REFUND_TICKET, 1, "退票");
                        }
//                      if (tInfo.getResign_flag().equals("Y")){
//                          //改签
//                          menu.add(A6OrderAty.CONTEXT_GROUP_0, A6OrderAty.CONTEXT_ITEM_RESIGN, 2, "改签");
//                      }
                    }
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
        });
        A6OrderItemAdapter adapter = new A6OrderItemAdapter(mContext, mLstDatas.get(groupPosition).getTickets());
        holder.slv1.setAdapter(adapter);
        return convertView;
    }
项目:AndroidViewHelper    文件:ViewWrapper.java   
/**
* @see View#setOnCreateContextMenuListener(OnCreateContextMenuListener)
*/
 public W setOnCreateContextMenuListener(OnCreateContextMenuListener l) {
     mView.setOnCreateContextMenuListener(l);
     return (W)this;
 }
项目:Rss-App-for-tumblr    文件:EntriesListActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    if (MainTabActivity.isLightTheme(this)) {
        setTheme(R.style.Theme_Light);
    }

    super.onCreate(savedInstanceState);

    feedName = null;

    iconBytes = null;

    Intent intent = getIntent();

    feedId = intent.getLongExtra(FeedData.FeedColumns._ID, 0);
    uri = intent.getData();

    if (feedId > 0) {
        Cursor cursor = getContentResolver().query(FeedData.FeedColumns.CONTENT_URI(feedId), FEED_PROJECTION, null, null, null);

        if (cursor.moveToFirst()) {
            feedName = cursor.isNull(0) ? cursor.getString(1) : cursor.getString(0);
            iconBytes = cursor.getBlob(2);
            hideRead = cursor.getInt(3) == 1;
        }
        cursor.close();
    } else {
        hideRead = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(new StringBuilder(uri.equals(FeedData.EntryColumns.FAVORITES_CONTENT_URI) ? FAVORITES : ALLENTRIES).append('.').append(FeedData.FeedColumns.HIDE_READ).toString(), false);
    }

    if (!MainTabActivity.POSTGINGERBREAD && iconBytes != null && iconBytes.length > 0) { // we cannot insert the icon here because it would be overwritten, but we have to reserve the icon here
        if (!requestWindowFeature(Window.FEATURE_LEFT_ICON)) {
            iconBytes = null;
        }
    }

    setContentView(R.layout.entries);

    entriesListAdapter = new EntriesListAdapter(this, uri, intent.getBooleanExtra(EXTRA_SHOWFEEDINFO, false), intent.getBooleanExtra(EXTRA_AUTORELOAD, false), hideRead);
    setListAdapter(entriesListAdapter);

    if (feedName != null) {
        setTitle(feedName);
    }
    if (iconBytes != null && iconBytes.length > 0) {
        int bitmapSizeInDip = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24f, getResources().getDisplayMetrics());
        Bitmap bitmap = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length);
        if (bitmap != null) {
            if (bitmap.getHeight() != bitmapSizeInDip) {
                bitmap = Bitmap.createScaledBitmap(bitmap, bitmapSizeInDip, bitmapSizeInDip, false);
            }

            if (MainTabActivity.POSTGINGERBREAD) {
                CompatibilityHelper.setActionBarDrawable(this, new BitmapDrawable(bitmap));
            } else {
                setFeatureDrawable(Window.FEATURE_LEFT_ICON, new BitmapDrawable(bitmap));
            }
        }
    }
    if (RSSOverview.notificationManager != null) {
        RSSOverview.notificationManager.cancel(0);
    }

    getListView().setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
            menu.setHeaderTitle(((TextView) ((AdapterView.AdapterContextMenuInfo) menuInfo).targetView.findViewById(android.R.id.text1)).getText());
            menu.add(0, CONTEXTMENU_MARKASREAD_ID, Menu.NONE, R.string.contextmenu_markasread).setIcon(android.R.drawable.ic_menu_manage);
            menu.add(0, CONTEXTMENU_MARKASUNREAD_ID, Menu.NONE, R.string.contextmenu_markasunread).setIcon(android.R.drawable.ic_menu_manage);
            //menu.add(0, CONTEXTMENU_DELETE_ID, Menu.NONE, R.string.contextmenu_delete).setIcon(android.R.drawable.ic_menu_delete);
            menu.add(0, CONTEXTMENU_COPYURL, Menu.NONE, R.string.contextmenu_copyurl).setIcon(android.R.drawable.ic_menu_share);
        }
    });
}
项目:Bluetooth_ChineseChess    文件:ArchiveManagerActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.archives_display);

    // ��Layout�����ListView
    list = (ListView) findViewById(R.id.archives_display_ListView);

    // ���ɶ�̬���飬��������
    listItem = new ArrayList<HashMap<String, Object>>();

    //��ȡ��Ϸ�浵
    String[] fileNames = archiveContorller.getArchiveDir();
    for(int i = 0; i<fileNames.length;i++){
        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("archives_display_ItemImage", R.drawable.icon);// ͼ����Դ��ID
        //map.put("archives_display_ItemText01", "�浵 " + (i+1));
        map.put("archives_display_ItemText01", "��Ϸ�浵 ");
        map.put("archives_display_ItemText02", fileNames[i].subSequence(0, fileNames[i].length()-4));
        listItem.add(map);
    }

    // ������������Item�Ͷ�̬�����Ӧ��Ԫ��
    listItemAdapter = new SimpleAdapter(this, listItem,// ����Դ
            R.layout.archives_display_item,// ListItem��XMLʵ��
            // ��̬������ImageItem��Ӧ������
            new String[] { "archives_display_ItemImage",
                    "archives_display_ItemText01",
                    "archives_display_ItemText02" },
            // ImageItem��XML�ļ������һ��ImageView,����TextView ID
            new int[] { R.id.archives_display_ItemImage,
                    R.id.archives_display_ItemText01,
                    R.id.archives_display_ItemText02 });

    // ��Ӳ�����ʾ
    list.setAdapter(listItemAdapter);


    // ��ӵ��
    list.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            //��ô浵����
            String fileName = (String)listItem.get(arg2).get("archives_display_ItemText02");
            fileName +=".txt";

            //������Ϸ������Ϣ
            boolean flag = archiveContorller.readArchiveFile(fileName);

            //����������Ϣ
            ChineseChess.resetChessmanPosition();

            //��ת����Ϸ����
            Intent intent = new Intent();
            intent.setClass(ArchiveManagerActivity.this, GameViewActivity.class);
            ArchiveManagerActivity.this.startActivity(intent);

            //setTitle("�����" + arg2 + "����Ŀ");
        }
    });

    // ��ӳ������
    list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
            menu.setHeaderTitle("�浵ѡ��");
            menu.add(0, 0, 0, "ɾ��");
            menu.add(0, 1, 0, "ȡ��");
        }
    });
}
项目:gloomy-dungeons-2    文件:ContextMenuCallbackGetter.java   
public OnCreateContextMenuListener getOnCreateContextMenuListener();
项目:laposte-android    文件:ContextMenuCallbackGetter.java   
public OnCreateContextMenuListener getOnCreateContextMenuListener();
项目:TflTravelAlerts    文件:ContextMenuCallbackGetter.java   
public OnCreateContextMenuListener getOnCreateContextMenuListener();