android.widget.ListView#setOnCreateContextMenuListener ( )源码实例Demo

下面列出了android.widget.ListView#setOnCreateContextMenuListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.music_listview, container, false);

    mListView = (ListView) rootView.findViewById(android.R.id.list);
    mListView.setOnCreateContextMenuListener(this);
    mListView.setOnItemClickListener(this);
    musicList.addAll(MusicDBHelper.getFavoriteMusicList(getActivity()));
    listAdapter = new MusicListAdapter(getActivity(), musicList, 1);
    mListView.setAdapter(listAdapter);

    registerMessage();

    return rootView;
}
 
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.music_listview, container, false);

    mListView = (ListView) rootView.findViewById(android.R.id.list);
    mListView.setOnCreateContextMenuListener(this);
    mListView.setOnItemClickListener(this);
    listAdapter = new MusicListAdapter(getActivity(), musicList, 1);
    mListView.setAdapter(listAdapter);


    new Thread(new Runnable() {
        @Override
        public void run() {
            loadMusic();
        }
    }).start();

    return rootView;
}
 
源代码3 项目: android   文件: MisUbicaciones.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	
	View view = inflater.inflate(R.layout.mis_ubicaciones, container, false);

       listaUbicaciones = new ArrayList<>();
       adapter = new UbicacionAdapter(getActivity(), R.layout.item_ubicacion, listaUbicaciones);
       ListView lvListaUbicaciones = (ListView) view.findViewById(R.id.lvListaUbicaciones);
       lvListaUbicaciones.setAdapter(adapter);
       lvListaUbicaciones.setOnItemClickListener(this);
       lvListaUbicaciones.setOnCreateContextMenuListener(this);
       registerForContextMenu(lvListaUbicaciones);
	
   	return view;
}
 
源代码4 项目: android   文件: MisUbicaciones.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	
	View view = inflater.inflate(R.layout.mis_ubicaciones, container, false);

       listaUbicaciones = new ArrayList<>();
       adapter = new UbicacionAdapter(getActivity(), R.layout.item_ubicacion, listaUbicaciones);
       ListView lvListaUbicaciones = (ListView) view.findViewById(R.id.lvListaUbicaciones);
       lvListaUbicaciones.setAdapter(adapter);
       lvListaUbicaciones.setOnItemClickListener(this);
       lvListaUbicaciones.setOnCreateContextMenuListener(this);
       registerForContextMenu(lvListaUbicaciones);
	
   	return view;
}
 
源代码5 项目: YiBo   文件: MyStatusesActivity.java
private void bindEvent() {
	Button btnBack = (Button)this.findViewById(R.id.btnBack);
	btnBack.setOnClickListener(new GoBackClickListener());

	Button btnOperate = (Button) this.findViewById(R.id.btnOperate);
	btnOperate.setVisibility(View.VISIBLE);
	btnOperate.setText(R.string.btn_home);
	btnOperate.setOnClickListener(new GoHomeClickListener());

	ListView lvMicroBlog = (ListView)this.findViewById(R.id.lvMicroBlog);
	lvMicroBlog.setOnItemClickListener(new MicroBlogItemClickListener(this));
	MicroBlogContextMenuListener contextMenuListener =
		new MicroBlogContextMenuListener(lvMicroBlog);
	lvMicroBlog.setOnCreateContextMenuListener(contextMenuListener);
	lvMicroBlog.setOnScrollListener(new StatusScrollListener());
}
 
源代码6 项目: styT   文件: FJActivity.java
/**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fj);

        toolbar = (android.support.v7.widget.Toolbar)
                findViewById(R.id.toolbar);
//		初始化Toolbar控件
        setSupportActionBar(toolbar);
        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, "移除该图片");
            }
        });
    }
 
源代码7 项目: android-pdk   文件: MyBoardsActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_boards);
    setTitle("My Boards");
    _boardsAdapter = new BoardsAdapter(this);
    _listView = (ListView) findViewById(R.id.listView);

    _listView.setAdapter(_boardsAdapter);
    _listView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v,
            ContextMenu.ContextMenuInfo menuInfo) {
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.context_menu_boards, menu);
        }
    });

    myBoardsCallback = new PDKCallback() {
        @Override
        public void onSuccess(PDKResponse response) {
            _loading = false;
            myBoardsResponse = response;
            _boardsAdapter.setBoardList(response.getBoardList());
        }

        @Override
        public void onFailure(PDKException exception) {
            _loading = false;
            Log.e(getClass().getName(), exception.getDetailMessage());
        }
    };
    _loading = true;
}
 
源代码8 项目: aedict   文件: DictEntryListActions.java
public DictEntryListActions register(final ListView lv) {
	lv.setOnCreateContextMenuListener(AndroidUtils.safe(activity, new View.OnCreateContextMenuListener() {

		public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
			final int position = ((AdapterContextMenuInfo) menuInfo).position;
			final DictEntry ee = (DictEntry) lv.getAdapter().getItem(position);
			register(menu, ee, position);
		}
	}));
	return this;
}
 
源代码9 项目: 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);
               }
               
           });
}
 
源代码10 项目: YiBo   文件: HotStatusesActivity.java
private void bindEvent() {
	Button btnBack = (Button)this.findViewById(R.id.btnBack);
	btnBack.setOnClickListener(new GoBackClickListener());

	Button btnOperate = (Button) this.findViewById(R.id.btnOperate);
	btnOperate.setVisibility(View.VISIBLE);
	btnOperate.setText(R.string.btn_home);
	btnOperate.setOnClickListener(new GoHomeClickListener());
	
	ListView  lvMicroBlog = (ListView)this.findViewById(R.id.lvMicroBlog);
	lvMicroBlog.setOnItemClickListener(new MicroBlogItemClickListener(this));
	MicroBlogContextMenuListener contextMenuListener =
		new MicroBlogContextMenuListener(lvMicroBlog);
	lvMicroBlog.setOnCreateContextMenuListener(contextMenuListener);
}
 
源代码11 项目: YiBo   文件: StatusSubscribeActivity.java
private void bindEvent() {
	Button btnBack = (Button)this.findViewById(R.id.btnBack);
	btnBack.setOnClickListener(new GoBackClickListener());

	Button btnOperate = (Button) this.findViewById(R.id.btnOperate);
	btnOperate.setVisibility(View.VISIBLE);
	btnOperate.setText(R.string.btn_home);
	btnOperate.setOnClickListener(new GoHomeClickListener());

	ListView lvMicroBlog = (ListView)this.findViewById(R.id.lvMicroBlog);
	lvMicroBlog.setOnItemClickListener(new MicroBlogItemClickListener(this));
	MicroBlogContextMenuListener contextMenuListener =
		new MicroBlogContextMenuListener(lvMicroBlog);
	lvMicroBlog.setOnCreateContextMenuListener(contextMenuListener);
}
 
源代码12 项目: 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, "移除该图片");
		}
	    });
    }
 
源代码13 项目: YiBo   文件: GroupTabChangeListener.java
@Override
public void onTabChange(View v, int which) {
	ListView lvUser = (ListView) context.findViewById(R.id.lvUser);
	Paging<?> paging = null;
	boolean isInit = false;
	switch (which) {
	case 0:
		SocialGraphListAdapter sgAdapter = context.getSgAdapter();
		if (sgAdapter == null) {
			sgAdapter = new SocialGraphListAdapter(context, 
				context.getCurrentAccount(), context.getSocialGraphType());
			context.setSgAdapter(sgAdapter);
			new SocialGraphTask(sgAdapter, context.getUser()).execute();
			isInit = true;
		}
		paging = sgAdapter.getPaging();
		lvUser.setAdapter(sgAdapter);
		lvUser.setOnItemClickListener(socialGraphItemClickListener);
           lvUser.setOnCreateContextMenuListener(null);
		break;
	case 1:
		GroupListAdapter groupAdapter = context.getGroupAdapter();
		if (groupAdapter == null) {
			groupAdapter = new GroupListAdapter(context, context.getCurrentAccount());
			context.setGroupAdapter(groupAdapter);
			groupContextMenuListener = new GroupContextMenuListener(groupAdapter);
			
			new GroupTask(groupAdapter).execute();
			isInit = true;
		}
		paging = groupAdapter.getPaging();
		lvUser.setAdapter(groupAdapter);
		lvUser.setOnItemClickListener(groupItemClickListener);
		lvUser.setOnCreateContextMenuListener(groupContextMenuListener);
		break;
	}
	
	if (isInit) {
		return;
	}
    if (paging.hasNext()) {
    	context.showMoreFooter();
    } else {
    	context.showNoMoreFooter();
    }
}
 
源代码14 项目: CSipSimple   文件: MessageFragment.java
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);
    

    ListView lv = getListView();
    lv.setOnCreateContextMenuListener(this);
    
}