本文整理匯總了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;
}
});
}
示例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();// 子線程--拿數據
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
});
}
示例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));
}
}
示例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);
}
示例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);
}
});
}
示例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));
}
示例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();
}
}
示例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;
}
});
}
示例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
// }
// }
}
示例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);
}