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


Java ListView.setOnItemLongClickListener方法代码示例

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


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

示例1: setListItemLongClick

import android.widget.ListView; //导入方法依赖的package包/类
private void setListItemLongClick(ListView listView) {
    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, final int pos, long id) {
            PopupMenu popup = new PopupMenu(TaskActivity.this, view);
            popup.inflate(R.menu.task_item);
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    TaskEntity task = (TaskEntity) mAdapter.getItem(pos - 1);
                    handleTaskPopupAction(item, task);
                    return true;
                }
            });
            popup.show();
            return true;
        }
    });
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:20,代码来源:TaskActivity.java

示例2: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
@Override
   protected void onCreate(Bundle savedInstanceState)
   {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_buff);
StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
       apkPathText = (TextView) findViewById(R.id.apkPathText);
apitils.KEY = "";//初始化
// 初始化控件
lv = (ListView) findViewById(R.id.lv_main);
adapter = new apiAdapter(this);
adapter.setList(list);
adapter.setUninstall(buff_ext.this);// 传入接口
lv.setAdapter(adapter);
lv.setOnItemClickListener(buff_ext.this);
lv.setOnItemLongClickListener(buff_ext.this);
sort = (TextView) findViewById(R.id.sort);
count = (TextView) findViewById(R.id.count);
size = (TextView) findViewById(R.id.size);
iv_asc = (ImageView) findViewById(R.id.iv_asc);
//img = (ImageView) findViewById(R.id.img3);
// donghua();
updateData();// 子线程--拿数据
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:25,代码来源:buff_ext.java

示例3: initWidgets

import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void initWidgets() {
    super.initWidgets();
    mLayoutBottom = (RelativeLayout) findViewById(R.id.kf5_bottom_layout);
    mFeedBackDetailBottomView = new FeedBackDetailBottomView(mActivity);
    mFeedBackDetailBottomView.setListener(this);
    mETContent = layoutListener.getEditText();
    mLayoutBottom.addView(mFeedBackDetailBottomView);
    mListView = (ListView) findViewById(R.id.kf5_activity_feed_back_details_listview);
    mListView.setOnScrollListener(this);
    mListView.setOnItemLongClickListener(this);
    mListView.addHeaderView(inflateHeaderView());
    mBackImg = (ImageView) findViewById(R.id.kf5_return_img);
    mBackImg.setOnClickListener(this);
    mRightView = (TextView) findViewById(R.id.kf5_right_text_view);
    mRightView.setOnClickListener(this);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:18,代码来源:FeedBackDetailsActivity.java

示例4: onCreateView

import android.widget.ListView; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_todo, container, false);
  toolbar = (Toolbar) view.findViewById(R.id.toolbar);
  toolbar.setTitle(getString(R.string.title_todo));
  toolbar.inflateMenu(R.menu.todo);
  toolbar.setOnMenuItemClickListener(this);

  listView = (ListView) view.findViewById(R.id.list_view);
  refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
  adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, localTodoData);
  listView.setAdapter(adapter);
  listView.setOnItemLongClickListener(this);
  refreshLayout.setOnRefreshListener(this);

  return view;
}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:19,代码来源:TodoFragment.java

示例5: setupViews

import android.widget.ListView; //导入方法依赖的package包/类
private void setupViews() {
    setTitle(AppConstants.APP_TITLE);
    setContentView(R.layout.activity_main);
    listview = (ListView) findViewById(R.id.listview);
    listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            nextSelection = tokenlist.get(i);
            startSupportActionMode(MainActivity.this);
            return true;
        }
    });
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setBackgroundColor(getResources().getColor(PIBLUE));
    if (getSupportActionBar() != null) {
        getSupportActionBar().setLogo(R.mipmap.ic_launcher);
        getSupportActionBar().setDisplayUseLogoEnabled(true);
    }
}
 
开发者ID:privacyidea,项目名称:privacyidea-authenticator,代码行数:21,代码来源:MainActivity.java

示例6: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.titleHistory);

    //noinspection ConstantConditions
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(this, R.color.historyHeader)));

    //Bundle extras = getIntent().getExtras();
    setContentView(R.layout.activity_show_list);

    try (TravelDAO dbTravel = new TravelDAO(this)) {
        data = dbTravel.selectHistory();
    }

    adapter = new HistoryAdapter(this, R.layout.show_history_row, data);
    ListView listView1 = (ListView) findViewById(R.id.listView1);
    listView1.setAdapter(adapter);
    listView1.setOnItemLongClickListener(this);
    listView1.setOnItemClickListener(this);
}
 
开发者ID:Baleine82,项目名称:TrainPonctuality,代码行数:22,代码来源:ShowHistoryActivity.java

示例7: onViewCreated

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // View management
    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);


    // Modify list view
    ListView lv = getListView();
    lv.setVerticalFadingEdgeEnabled(true);
    // lv.setCacheColorHint(android.R.color.transparent);
    if (mDualPane) {
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        lv.setItemsCanFocus(false);
    } else {
        lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
        lv.setItemsCanFocus(true);
    }
    
    // Map long press
    lv.setLongClickable(true);
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> ad, View v, int pos, long id) {
            turnOnActionMode();
            getListView().setItemChecked(pos, true);
            mMode.invalidate();
            return true;
        }
    });
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:34,代码来源:CallLogListFragment.java

示例8: onViewCreated

import android.widget.ListView; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    final Resources res = getActivity().getResources();

    fab = (FloatingActionButton)view.findViewById(R.id.fab);
    fab.setOnClickListener(this);
    if(isTelevision()){
        fab.setVisibility(View.GONE);
    }

    mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);
    mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);
    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    if(isTelevision()) {
        mListView.setOnItemLongClickListener(mItemLongClickListener);
    }
    fab.attachToListView(mListView);

    // Indent our list divider to align with text
    final Drawable divider = mListView.getDivider();
    final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
    final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
    if (insetLeft) {
        mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
    } else {
        mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:30,代码来源:ConnectionsFragment.java

示例9: setupTableDataView

import android.widget.ListView; //导入方法依赖的package包/类
private void setupTableDataView(final AttributeSet attributes, final int styleAttributes) {
    final LayoutParams dataViewLayoutParams = new LayoutParams(getWidthAttribute(attributes), LayoutParams.MATCH_PARENT);

    if (isInEditMode()) {
        tableDataAdapter = new EditModeTableDataAdapter(getContext());
    } else {
        tableDataAdapter = new DefaultTableDataAdapter(getContext());
    }
    tableDataAdapter.setRowBackgroundProvider(dataRowBackgroundProvider);

    tableDataView = new ListView(getContext(), attributes, styleAttributes);

    tableDataView.setOnItemClickListener(new InternalDataClickListener());
    tableDataView.setOnItemLongClickListener(new InternalDataLongClickListener());
    tableDataView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    tableDataView.setAdapter(tableDataAdapter);
    tableDataView.setId(R.id.table_data_view);
    tableDataView.setOnScrollListener(new InternalOnScrollListener());

    swipeRefreshLayout = new SwipeRefreshLayout(getContext());
    swipeRefreshLayout.setLayoutParams(dataViewLayoutParams);
    swipeRefreshLayout.addView(tableDataView);
    swipeRefreshLayout.setColorSchemeColors(headerColor);
    swipeRefreshLayout.setEnabled(false);

    addView(swipeRefreshLayout);
}
 
开发者ID:datalink747,项目名称:Sortable_tableview_soussidev,代码行数:28,代码来源:TableView.java

示例10: InitView

import android.widget.ListView; //导入方法依赖的package包/类
private void InitView() {
    listView = (ListView) findViewById(R.id.listview);
    dataList = new ArrayList<Map<String, Object>>();//映射条目
    fab_editnote = (FloatingActionButton) findViewById(R.id.fab_editnote);
    DbHelper = new Database(this);
    DB = DbHelper.getReadableDatabase();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        //沉浸状态栏
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //沉浸导航栏
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }

    listView.setOnItemClickListener(this);
    listView.setOnItemLongClickListener(this);

    fab_editnote.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, NoteEdit.class);
            Bundle bundle = new Bundle();
            bundle.putString("info", "");
            bundle.putInt("enter_state", 0);
            intent.putExtras(bundle);
            startActivity(intent);
        }
    });
}
 
开发者ID:LibraTang,项目名称:Mingnote,代码行数:29,代码来源:MainActivity.java

示例11: initContactListView

import android.widget.ListView; //导入方法依赖的package包/类
private void initContactListView() {
    contactListView = (ListView) curView.findViewById(R.id.ContactListView);
    contactListView.setOnItemClickListener(this);
    contactListView.setOnItemLongClickListener(this);
    contactAdapter = new  ChatAdapter(getActivity());
    contactListView.setAdapter(contactAdapter);

    // this is critical, disable loading when finger sliding, otherwise
    // you'll find sliding is not very smooth
    contactListView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(),
            true, true));
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:13,代码来源:ChatFragment.java

示例12: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	// 设置主界面布局文件
	setContentView(R.layout.string_list);
	// 初始化列表控件
	stringListView = (ListView) findViewById(R.id.list_res_string);
	// 初始化显示资源类型的文本框
	textCategory = (TextView) findViewById(R.id.textCategory);
	// 初始化显示资源Config的文本框
	textConfig = (TextView) findViewById(R.id.textConfig);
	// 初始化翻译按钮
	btnTranslate = (ImageView) findViewById(R.id.btnTranslate);
	// 初始化搜索按钮
	btnSearch = (ImageView) findViewById(R.id.btnSearch);
	// 初始化保存按钮
	btnSave = (ImageView) findViewById(R.id.btnSave);
	// 获取用来显示信息的文本框
	info = (TextView) findViewById(R.id.info);
	// 为显示资源类型的文本框设置点击事件的监听器
	textCategory.setOnClickListener(MyOnClickListener);
	// 为显示资源Config的文本框设置点击事件的监听器
	textConfig.setOnClickListener(MyOnClickListener);
	// 为显示资源类型的文本框设置文本内容改变的监听器
	textCategory.addTextChangedListener(textWatcher);
	// 为显示资源Config的文本框设置文本内容改变的监听器
	textConfig.addTextChangedListener(textWatcher);
	// 为翻译按钮设置点击事件监听器
	btnTranslate.setOnClickListener(MyOnClickListener);
	// 为搜索按钮设置点击事件监听器
	btnSearch.setOnClickListener(MyOnClickListener);
	// 为保存按钮设置点击事件监听器
	btnSave.setOnClickListener(MyOnClickListener);
	// 初始化数据适配器
	mAdapter = new stringListAdapter(this);
	// 为列表控件设置数据适配器
	stringListView.setAdapter(mAdapter);
	// 为列表控件设置长按事件监听器
	stringListView.setOnItemLongClickListener(this);
	try {
		open("/sdcard/resources.arsc");
	} catch (IOException e) {
		showMessage(this, e.toString()).show();
	}
}
 
开发者ID:seaase,项目名称:ArscEditor,代码行数:46,代码来源:MainActivity.java

示例13: onCreate

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

    // Get the preferences
    SharedPreferences prefs = PreferenceManager
            .getDefaultSharedPreferences(this);
    Gson gson = new Gson();
    String json = prefs.getString(PREF_APPDETAILS_APP_NAMES, "");
    String[] appNames = gson.fromJson(json, String[].class);
    createAppDetailsFromAppNames(appNames);

    // Handle long click in the ListView
    final ListView lv = getListView();
    lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener
            () {
        @Override
        public boolean onItemLongClick(AdapterView<?> av, View view,
                                       final int pos, long id) {
            final CharSequence[] items = {
                    getText(R.string.app_details_edit),
                    getText(R.string.app_details_delete),
                    getText(R.string.app_details_add),
                    getText(R.string.app_details_move_up),
                    getText(R.string.app_details_move_down),
            };
            AlertDialog.Builder builder =
                    new AlertDialog.Builder(AppDetailsActivity.this);
            builder.setTitle(getText(R.string.app_details_modify));
            builder.setSingleChoiceItems(items, 0,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int
                                item) {
                            dialog.dismiss();
                            switch (item) {
                                case 0:
                                    editItem(pos);
                                    break;
                                case 1:
                                    deleteItem(pos);
                                    break;
                                case 2:
                                    addItem(pos);
                                    break;
                                case 3:
                                    moveItemUp(pos);
                                    break;
                                case 4:
                                    moveItemDown(pos);
                                    break;
                            }
                        }
                    });
            AlertDialog alert = builder.create();
            alert.show();
            // Need to return true or it will call the onClickListener
            return true;
        }
    });
}
 
开发者ID:KennethEvans,项目名称:Misc,代码行数:61,代码来源:AppDetailsActivity.java

示例14: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState, Intent intent,
                            CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList,
                            boolean alwaysUseOption, int userid) {
        super.onCreate(savedInstanceState);
        mLaunchedFromUid = userid;
        mPm = getPackageManager();
        mAlwaysUseOption = alwaysUseOption;
        mMaxColumns = getResources().getInteger(R.integer.config_maxResolverActivityColumns);

        mRegistered = true;

        final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        mIconDpi = am.getLauncherLargeIconDensity();
        mIconSize = am.getLauncherLargeIconSize();

        mAdapter = new ResolveListAdapter(this, intent, initialIntents, rList,
                mLaunchedFromUid);
        int count = mAdapter.getCount();
        if (Build.VERSION.SDK_INT >= 17) {
            if (mLaunchedFromUid < 0) {
                // Gulp!
                finish();
                return;
            }
        }

        if (count == 1) {
            startSelected(0, false);
            mRegistered = false;
            finish();
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(title);
        if (count > 1) {
            mListView = new ListView(this);
            mListView.setAdapter(mAdapter);
            mListView.setOnItemClickListener(this);
            mListView.setOnItemLongClickListener(new ItemLongClickListener());
            builder.setView(mListView);
            if (alwaysUseOption) {
                mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
            }
        } else {
            builder.setMessage(R.string.noApplications);
        }
        builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });
        dialog = builder.show();
//
//        if (alwaysUseOption) {
//            final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar);
//            if (buttonLayout != null) {
//                buttonLayout.setVisibility(View.VISIBLE);
//                mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
//                mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once);
//            } else {
//                mAlwaysUseOption = false;
//            }
//            // Set the initial highlight if there was a preferred or last used choice
//            final int initialHighlight = mAdapter.getInitialHighlight();
//            if (initialHighlight >= 0) {
//                mListView.setItemChecked(initialHighlight, true);
//                onItemClick(null, null, initialHighlight, 0); // Other entries are not used
//            }
//        }
    }
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:72,代码来源:ResolverActivity.java

示例15: onCreate

import android.widget.ListView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppThemeStaffLogin);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_desk_basket);

    lvBasket= (ListView) findViewById(R.id.lvBasket);
    lvBasket.setOnItemLongClickListener(this);
    lvBasket.setOnItemClickListener(this);
    productList = new ArrayList<>();

    btnOrderVerify = (FlatButton) findViewById(R.id.btnOrderVerify);
    btnOrderVerify.setOnClickListener(this);

    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_SHOW_CUSTOM);
    getSupportActionBar().setCustomView(R.layout.custom_actionbar);
    tvActionBar = (TextView)getSupportActionBar().getCustomView().findViewById(R.id.tvActionBar);
    tvActionBar.setText(getResources().getString(R.string.staffDeskBasketHeader));
    tvActionBar.setTextAppearance(this, android.R.style.TextAppearance_Large);
    tvActionBar.setTextColor(Color.WHITE);

    orderId = getIntent().getIntExtra("orderId",-1);
    status = getIntent().getIntExtra("status",-1);
    url+=orderId;

    if (status == 0){
        btnOrderVerify.setBackgroundColor(getResources().getColor(R.color.status0));
        btnOrderVerify.setText("SİPARİŞ YOK");
        btnOrderVerify.setClickable(false);
    }else if (status == 1){
        btnOrderVerify.setBackgroundColor(getResources().getColor(R.color.status1));
        btnOrderVerify.setText("SİPARİŞİ ONAYLA");
        btnOrderVerify.setClickable(true);
    }else{
        btnOrderVerify.setBackgroundColor(getResources().getColor(R.color.status2));
        btnOrderVerify.setText("SİPARİŞ ONAYLANMIŞ");
        btnOrderVerify.setClickable(false);
    }

    Request request = new Request(this, url, com.android.volley.Request.Method.GET);
    request.requestVolleyDeskList(this);

}
 
开发者ID:yusufcakal,项目名称:RestaurantApp,代码行数:44,代码来源:DeskBasketActivity.java


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