当前位置: 首页>>代码示例>>Java>>正文


Java ListView.setOnCreateContextMenuListener方法代码示例

本文整理汇总了Java中android.widget.ListView.setOnCreateContextMenuListener方法的典型用法代码示例。如果您正苦于以下问题:Java ListView.setOnCreateContextMenuListener方法的具体用法?Java ListView.setOnCreateContextMenuListener怎么用?Java ListView.setOnCreateContextMenuListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ListView的用法示例。


在下文中一共展示了ListView.setOnCreateContextMenuListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	activity = getActivity();
	context = activity.getApplicationContext();
	RelativeLayout downloadLayout = new RelativeLayout(activity.getApplicationContext());
	downloadLayout.setBackgroundColor(Color.WHITE);
	receiver = new DownloadedReceiver();
	activity.registerReceiver(receiver, new IntentFilter(ConfigUtil.ACTION_DOWNLOADED));
	
	downloadedListView = new ListView(context);
	downloadedListView.setPadding(10, 10, 10, 10);
	downloadedListView.setDivider(getResources().getDrawable(R.drawable.line));
	LayoutParams downloadedLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	downloadLayout.addView(downloadedListView, downloadedLayoutParams);
	
	initData();

	downloadedListView.setOnItemClickListener(onItemClickListener);
	downloadedListView.setOnCreateContextMenuListener(onCreateContextMenuListener);

	return downloadLayout;
}
 
开发者ID:lbbniu,项目名称:CCDownload,代码行数:23,代码来源:DownloadedFragment.java

示例2: onCreateView

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	activity = getActivity();
	context = activity.getApplicationContext();
	receiver = new UploadReceiver();
	activity.registerReceiver(receiver, new IntentFilter(ConfigUtil.ACTION_UPLOAD));
	service = new Intent(context, UploadService.class);
	
	binderService();
	
	RelativeLayout view = new RelativeLayout(context);
	view.setBackgroundColor(Color.WHITE);
	LayoutParams uploadLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	uploadListView = new ListView(context);
	uploadListView.setDivider(getResources().getDrawable(R.drawable.line));
	view.addView(uploadListView, uploadLayoutParams);

	uploadListView.setOnItemClickListener(onItemClickListener);
	uploadListView.setOnCreateContextMenuListener(onCreateContextMenuListener);
	
	initUploadList();
	
	LayoutParams uploadButtonLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	uploadButtonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	uploadButtonLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
	
	uploadButton = new Button(context);
	view.addView(uploadButton, uploadButtonLayoutParams);
	uploadButton.setText("上传");
	uploadButton.setTextColor(0xFFFFFFFF);
	uploadButton.setOnClickListener(uploadOnClickListener);
	
	timer.schedule(timerTask, 0, 1000);
	return view;
}
 
开发者ID:lbbniu,项目名称:CCDownload,代码行数:36,代码来源:UploadFragment.java

示例3: initView

import android.widget.ListView; //导入方法依赖的package包/类
private void initView(RelativeLayout view ){
	view.setBackgroundColor(Color.WHITE);
	LayoutParams downloadingLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	downloadingListView = new ListView(context);
	downloadingListView.setPadding(10, 10, 10, 10);
	downloadingListView.setDivider(getResources().getDrawable(R.drawable.line));
	view.addView(downloadingListView, downloadingLayoutParams);
	
	downloadingListView.setOnItemClickListener(onItemClickListener);
	downloadingListView.setOnCreateContextMenuListener(onCreateContextMenuListener);
	
}
 
开发者ID:lbbniu,项目名称:CCDownload,代码行数:13,代码来源:DownloadingFragment.java

示例4: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
/** 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, "移除该图片");
		}
	    });
    }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:46,代码来源:FJActivity.java

示例5: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
    if (DBG) Log.d(TAG, "onCreate");
    super.onCreate(icicle);

    setContentView(R.layout.subtitles_wizard_main);

    // Extract the path of the video to handle from the intent
    Uri videoUri = getIntent().getData();
    // FIXME: this is broken for smb:// files
    if (videoUri != null) {
        mVideoUri = videoUri;
        mVideoPath = videoUri.getPath();
        if (DBG) Log.d(TAG, "onCreate : video to process = " + mVideoPath);

        if (mVideoPath != null) {
            File videoFile = new File(mVideoPath);

            // Retrieve the list of subtitles files already associated with the video
            mCurrentFilesCount = buildCurrentSubtitlesFilesList(mVideoPath);
            if (DBG) Log.d(TAG, "onCreate : mCurrentFilesCount = " + mCurrentFilesCount);

            // Get the list of subtitles files available in the current folder
            mAvailableFilesCount = buildAvailableSubtitlesFilesList(videoFile.getParent());
            if (DBG) Log.d(TAG, "onCreate : mAvailableFilesCount = " + mAvailableFilesCount);
        }
    }
    else {
        // Bad intent
        Log.e(TAG, "onCreate error : no folder provided");
        mVideoUri = null;
    }

    // Use the name of the video to build the help message displayed at the top of the screen
    TextView helpMessageHeader = (TextView) findViewById(R.id.help_message_header);
    String name = Utils.getFileNameWithoutExtension(mVideoUri);

    String helpMessage;
    if (mAvailableFilesCount == 0 && mCurrentFilesCount == 0) {
        helpMessage = getString(R.string.subtitles_wizard_empty_list_help).replace("%s", name);
    }
    else {
        helpMessage = getString(R.string.subtitles_wizard_help).replace("%s", name);
    }
    helpMessageHeader.setText(helpMessage);

    // Inflate the view to show if no subtitles files are found
    mEmptyView = (TextView) LayoutInflater.from(this).inflate(R.layout.browser_empty_item, null);

    mListView = (ListView) findViewById(R.id.list_items);
    mListView.setEmptyView(mEmptyView);

    SubtitlesWizardAdapter adapter = new SubtitlesWizardAdapter(getApplication(), this);
    mListView.setAdapter(adapter);
    mListView.setCacheColorHint(0);
    mListView.setOnItemClickListener(this);
    mListView.setOnCreateContextMenuListener(this);
    mListView.setSelector(R.drawable.list_selector_no_background);

    //mDefaultIconsColor = getResources().getColor(R.color.default_icons_color_filter);
    
    // Handle the message to display when there are no files
    enableEmptyView(mAvailableFilesCount == 0 && mCurrentFilesCount == 0);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:65,代码来源:SubtitlesWizardActivity.java

示例6: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
@Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        getWindow().setFlags(LayoutParams.FLAG_NOT_TOUCH_MODAL, LayoutParams.FLAG_NOT_TOUCH_MODAL);
        getWindow().setFlags(LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);

        // Notify the application that the activity has started
        CustomApplication app = (CustomApplication)getApplication();
        app.setAutoScraperActive(true);
        mScraper = new Scraper(this);

        // Check if the intent which created this activity contains a folder path
        Uri folderUri = getIntent().getData();
        if (folderUri != null) {
            mFolderMode = true;
            // FIXME: this is broken for smb:// files
            mFolderPath = folderUri.getPath();
            if (DBG) Log.d(TAG, "onCreate : search in folder " + mFolderPath);
        }
        else {
            mFolderMode = false;
            mFolderPath = null;
            if (DBG) Log.d(TAG, "onCreate : search in the full database");
        }

        setContentView(R.layout.auto_scraper_main);

        mMainView = findViewById(R.id.main_view);
        mAbortButton = (Button)findViewById(R.id.abort_button);
        mAbortButton.setOnClickListener(this);
        mExitButton = (Button)findViewById(R.id.exit_button);
        mExitButton.setOnClickListener(this);

        mListView = (ListView) findViewById(R.id.list_items);
        mListView.setTextFilterEnabled(true);
        mListView.setCacheColorHint(0);
        mListView.setSelector(R.drawable.list_selector_no_background);
        mListView.setOnCreateContextMenuListener(this);
        mListView.setOnScrollListener(this);
        mListView.setOnKeyListener(this);

        mActivityFileCursor = getFileListCursor();
        getColumnIndices(mActivityFileCursor);
        buildFileProperties(mActivityFileCursor);
        mAdapterFileCursor = buildAdapterCursor(mActivityFileCursor);

        mAdapter = new AutoScraperAdapter(getApplication(), this,
                                          R.layout.auto_scraper_item,
                                          mAdapterFileCursor);
        mListView.setAdapter(mAdapter);
/*
        if (!mListView.isInTouchMode()) {
            // The application is remotely controlled => set the focus by default
            // on the Cancel button so that the user can abort the task with a 
            // single click instead of navigating the full ListView
            mAbortButton.requestFocus();
        }
*/
        mEmptyView = buildEmptyView();
        mListView.setEmptyView(mEmptyView);
        updateControlButtons(false);
        if (mFileCount > 0) {
            mMainView.setVisibility(View.VISIBLE);
        }
        else {
            mMainView.setVisibility(View.GONE);
        }

        mIsLargeScreen = getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)|| TVUtils.isTV(this);

        PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
        mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "AutoScraperActivity");
    }
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:75,代码来源:AutoScraperActivity.java

示例7: onActivityCreated

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);
    

    ListView lv = getListView();
    lv.setOnCreateContextMenuListener(this);
    
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:11,代码来源:MessageFragment.java


注:本文中的android.widget.ListView.setOnCreateContextMenuListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。