Java Code Examples for android.widget.listview#setOnCreateContextMenuListener()

The following examples show how to use android.widget.listview#setOnCreateContextMenuListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MusicLoveListFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
@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;
}
 
Example 2
Source File: MusicAllListFragment.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
@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;
}
 
Example 3
Source File: MisUbicaciones.java    From android with GNU General Public License v2.0 6 votes vote down vote up
@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;
}
 
Example 4
Source File: MisUbicaciones.java    From android with GNU General Public License v2.0 6 votes vote down vote up
@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;
}
 
Example 5
Source File: MyStatusesActivity.java    From YiBo with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 6
Source File: FJActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
/**
     * 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, "移除该图片");
            }
        });
    }
 
Example 7
Source File: MyBoardsActivity.java    From android-pdk with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 8
Source File: DictEntryListActions.java    From aedict with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 9
Source File: BookshelfActivity.java    From coolreader with MIT License 5 votes vote down vote up
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);
               }
               
           });
}
 
Example 10
Source File: HotStatusesActivity.java    From YiBo with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: StatusSubscribeActivity.java    From YiBo with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 12
Source File: FJActivity.java    From stynico with MIT License 4 votes vote down vote up
/** 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, "移除该图片");
		}
	    });
    }
 
Example 13
Source File: GroupTabChangeListener.java    From YiBo with Apache License 2.0 4 votes vote down vote up
@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();
    }
}
 
Example 14
Source File: MessageFragment.java    From CSipSimple with GNU General Public License v3.0 3 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);
    

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