本文整理汇总了Java中android.widget.Button.setOnLongClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setOnLongClickListener方法的具体用法?Java Button.setOnLongClickListener怎么用?Java Button.setOnLongClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Button
的用法示例。
在下文中一共展示了Button.setOnLongClickListener方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: displayAttachmentInformation
import android.widget.Button; //导入方法依赖的package包/类
private void displayAttachmentInformation() {
viewButton = (Button) findViewById(R.id.view);
downloadButton = (Button) findViewById(R.id.download);
if (attachment.size > QMail.MAX_ATTACHMENT_DOWNLOAD_SIZE) {
viewButton.setVisibility(View.GONE);
downloadButton.setVisibility(View.GONE);
}
viewButton.setOnClickListener(this);
downloadButton.setOnClickListener(this);
downloadButton.setOnLongClickListener(this);
TextView attachmentName = (TextView) findViewById(R.id.attachment_name);
attachmentName.setText(attachment.displayName);
setAttachmentSize(attachment.size);
refreshThumbnail();
}
示例2: onCreate
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second_layout);
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction tx = fm.beginTransaction();
BlankFragment blankFragment = new BlankFragment();
tx.add(R.id.id_content, blankFragment, "ONE");
tx.commit();
blankFragment.onLowMemory();
Button b = (Button) findViewById(R.id.test_click);
b.setOnClickListener(this);
b.setOnLongClickListener(this);
}
示例3: MyHolder
import android.widget.Button; //导入方法依赖的package包/类
public MyHolder(View v)
{
super(v);
button = (Button) v.findViewById(R.id.button);
button.setOnLongClickListener(this);
}
示例4: onCreate
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1 = (Button) findViewById(R.id.onePlus);
btn10 = (Button) findViewById(R.id.tenPlus);
btn100 = (Button) findViewById(R.id.hunderdPlus);
btn1.setOnLongClickListener(this);
btn10.setOnLongClickListener(this);
btn100.setOnLongClickListener(this);
}
示例5: initView
import android.widget.Button; //导入方法依赖的package包/类
private void initView() {
mEditText= (EditText) findViewById(R.id.mEditText);
mImageView= (ImageView) findViewById(R.id.mImageView);
mTextView= (TextView) findViewById(R.id.mTextView);
btn_0= (Button) findViewById(R.id.btn_0);
btn_0.setOnClickListener(this);
btn_1= (Button) findViewById(R.id.btn_1);
btn_1.setOnClickListener(this);
btn_2= (Button) findViewById(R.id.btn_2);
btn_2.setOnClickListener(this);
btn_3= (Button) findViewById(R.id.btn_3);
btn_3.setOnClickListener(this);
btn_4= (Button) findViewById(R.id.btn_4);
btn_4.setOnClickListener(this);
btn_5= (Button) findViewById(R.id.btn_5);
btn_5.setOnClickListener(this);
btn_6= (Button) findViewById(R.id.btn_6);
btn_6.setOnClickListener(this);
btn_7= (Button) findViewById(R.id.btn_7);
btn_7.setOnClickListener(this);
btn_8= (Button) findViewById(R.id.btn_8);
btn_8.setOnClickListener(this);
btn_9= (Button) findViewById(R.id.btn_9);
btn_9.setOnClickListener(this);
btn_del= (Button) findViewById(R.id.btn_del);
btn_del.setOnClickListener(this);
btn_query= (Button) findViewById(R.id.btn_query);
btn_query.setOnClickListener(this);
btn_del.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
mEditText.setText("");
mTextView.setVisibility(View.GONE);
mImageView.setVisibility(View.GONE);
return false;
}
});
}
示例6: initView
import android.widget.Button; //导入方法依赖的package包/类
private void initView() {
et_number = (EditText) findViewById(R.id.et_number);
iv_company = (ImageView) findViewById(R.id.iv_company);
tv_result = (TextView) findViewById(R.id.tv_result);
btn_0 = (Button) findViewById(R.id.btn_0);
btn_0.setOnClickListener(this);
btn_1 = (Button) findViewById(R.id.btn_1);
btn_1.setOnClickListener(this);
btn_2 = (Button) findViewById(R.id.btn_2);
btn_2.setOnClickListener(this);
btn_3 = (Button) findViewById(R.id.btn_3);
btn_3.setOnClickListener(this);
btn_4 = (Button) findViewById(R.id.btn_4);
btn_4.setOnClickListener(this);
btn_5 = (Button) findViewById(R.id.btn_5);
btn_5.setOnClickListener(this);
btn_6 = (Button) findViewById(R.id.btn_6);
btn_6.setOnClickListener(this);
btn_7 = (Button) findViewById(R.id.btn_7);
btn_7.setOnClickListener(this);
btn_8 = (Button) findViewById(R.id.btn_8);
btn_8.setOnClickListener(this);
btn_9 = (Button) findViewById(R.id.btn_9);
btn_9.setOnClickListener(this);
btn_del = (Button) findViewById(R.id.btn_del);
btn_del.setOnClickListener(this);
btn_query = (Button) findViewById(R.id.btn_query);
btn_query.setOnClickListener(this);
//长按事件
btn_del.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
et_number.setText("");
return false;
}
});
}
示例7: onFinishInflate
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
super.onFinishInflate();
summaryView = (TextView) findViewById(R.id.summary);
summaryLabel = (TextView) findViewById(R.id.summary_label);
organizerView = (TextView) findViewById(R.id.organizer);
organizerLabel = (TextView) findViewById(R.id.organizer_label);
requiredView = (TextView) findViewById(R.id.required);
requiredLabel = (TextView) findViewById(R.id.required_label);
optionalView = (TextView) findViewById(R.id.optional);
optionalLabel = (TextView) findViewById(R.id.optional_label);
fyiView = (TextView) findViewById(R.id.fyi);
fyiLabel = (TextView) findViewById(R.id.fyi_label);
locationView = (TextView) findViewById(R.id.location);
locationLabel = (TextView) findViewById(R.id.location_label);
dateTimeView = (TextView) findViewById(R.id.date_time);
dateTimeLabel = (TextView) findViewById(R.id.date_time_label);
mRecurrenceView = (TextView) findViewById(R.id.recurrence);
mFontSizes.setViewTextSize(organizerView, mFontSizes.getICalendarViewOrganizer());
mFontSizes.setViewTextSize(organizerLabel, mFontSizes.getICalendarViewOrganizer());
mFontSizes.setViewTextSize(requiredView, mFontSizes.getICalendarViewRequired());
mFontSizes.setViewTextSize(requiredLabel, mFontSizes.getICalendarViewRequired());
mFontSizes.setViewTextSize(optionalView, mFontSizes.getICalendarViewOptional());
mFontSizes.setViewTextSize(optionalLabel, mFontSizes.getICalendarViewOptional());
mFontSizes.setViewTextSize(locationView, mFontSizes.getICalendarViewLocation());
mFontSizes.setViewTextSize(locationLabel, mFontSizes.getICalendarViewLocation());
mFontSizes.setViewTextSize(dateTimeView, mFontSizes.getICalendarViewDateTime());
mFontSizes.setViewTextSize(dateTimeLabel, mFontSizes.getICalendarViewDateTime());
mFontSizes.setViewTextSize(mRecurrenceView, mFontSizes.getICalendarViewDateTime());
viewButton = (Button) findViewById(R.id.view);
downloadButton = (Button) findViewById(R.id.download);
viewButton.setOnClickListener(this);
downloadButton.setOnClickListener(this);
downloadButton.setOnLongClickListener(this);
}
示例8: onCreate
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
manager = new EdSliderManager(new SelectedListener());
list = new ArrayList<String>();
for (int i = 0; i < 6; i ++)
{
list.add("Button " + i);
}
recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(
new LinearLayoutManager(MainActivity.this, LinearLayoutManager.VERTICAL, false));
recyclerView.setAdapter(
new MyAdapter(MainActivity.this, manager, list));
layoutTest = (LinearLayout) findViewById(R.id.layoutTest);
radioLeft = (AppCompatRadioButton) findViewById(R.id.radioLeft);
radioRight = (AppCompatRadioButton) findViewById(R.id.radioRight);
radioCenter = (AppCompatRadioButton) findViewById(R.id.radioCenter);
radioTop = (AppCompatRadioButton) findViewById(R.id.radioTop);
radioBottom = (AppCompatRadioButton) findViewById(R.id.radioBottom);
button = (Button) findViewById(R.id.button);
CheckChangedListener radioChangedListener = new CheckChangedListener();
radioLeft.setOnCheckedChangeListener(radioChangedListener);
radioRight.setOnCheckedChangeListener(radioChangedListener);
radioCenter.setOnCheckedChangeListener(radioChangedListener);
radioTop.setOnCheckedChangeListener(radioChangedListener);
radioBottom.setOnCheckedChangeListener(radioChangedListener);
button.setOnLongClickListener(new LongClickListener());
alignHorizontal = Align.LEFT;
alignVertical = Align.TOP;
}
示例9: initView
import android.widget.Button; //导入方法依赖的package包/类
private void initView()
{
et_phone_number= (EditText) findViewById(R.id.et_phone_number);
iv_company= (ImageView) findViewById(R.id.iv_company);
tv_phone_info= (TextView) findViewById(R.id.tv_phone_info);
btn_number_one= (Button) findViewById(R.id.btn_number_one);
btn_number_two= (Button) findViewById(R.id.btn_number_two);
btn_number_three= (Button) findViewById(R.id.btn_number_three);
btn_number_four= (Button) findViewById(R.id.btn_number_four);
btn_number_five= (Button) findViewById(R.id.btn_number_five);
btn_number_six= (Button) findViewById(R.id.btn_number_six);
btn_number_seven= (Button) findViewById(R.id.btn_number_seven);
btn_number_eight= (Button) findViewById(R.id.btn_number_eight);
btn_number_nine = (Button) findViewById(R.id.btn_number_nine);
btn_number_zero= (Button) findViewById(R.id.btn_number_zero);
btn_number_del= (Button) findViewById(R.id.btn_number_del);
btn_number_query= (Button) findViewById(R.id.btn_number_query);
//设置单点击监听器
btn_number_one.setOnClickListener(this);
btn_number_two.setOnClickListener(this);
btn_number_three.setOnClickListener(this);
btn_number_four.setOnClickListener(this);
btn_number_five.setOnClickListener(this);
btn_number_six.setOnClickListener(this);
btn_number_seven.setOnClickListener(this);
btn_number_eight.setOnClickListener(this);
btn_number_nine.setOnClickListener(this);
btn_number_zero.setOnClickListener(this);
btn_number_del.setOnClickListener(this);
btn_number_query.setOnClickListener(this);
//设置长按监听器
btn_number_del.setOnLongClickListener(new View.OnLongClickListener()
{
@Override
public boolean onLongClick(View v)
{
//长按删除键清空已输入的手机号
et_phone_number.setText("");
return false;
}
});
}
示例10: getView
import android.widget.Button; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Project project = mProjects.get(position);
if(convertView == null) {
LayoutInflater inflater = LayoutInflater.from(MBApp.getApp());
convertView = inflater.inflate(R.layout.project_items, null);
}
Button appNameButton = (Button) convertView.findViewById(R.id.appNameButton);
appNameButton.setTypeface(MBApp.getApp().getRobotoTypeface());
ExtendedEditText appNameEdit = (ExtendedEditText) convertView.findViewById(R.id.appNameEdit);
appNameEdit.setTypeface(MBApp.getApp().getRobotoTypeface());
LinearLayout actionBarLayout = (LinearLayout) convertView.findViewById(R.id.actionBarForProgram);
if(actionBarLayout != null) {
if(project.actionBarExpanded) {
actionBarLayout.setVisibility(View.VISIBLE);
appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
, R.drawable.ic_arrow_down), null);
} else {
actionBarLayout.setVisibility(View.GONE);
appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
, R.drawable.ic_arrow_left), null);
}
}
appNameButton.setText(project.name);
appNameButton.setTag(R.id.positionId, position);
appNameButton.setTag(R.id.textEdit, appNameEdit);
appNameButton.setOnClickListener(appNameClickListener);
appNameButton.setOnLongClickListener(appNameLongClickListener);
appNameEdit.setTag(R.id.positionId, position);
appNameEdit.setTag(R.id.editbutton, appNameButton);
appNameEdit.setOnEditorActionListener(editorOnActionListener);
appNameEdit.setFilters(new InputFilter[]{renameFilter});
if(project.inEditMode) {
appNameEdit.setVisibility(View.VISIBLE);
appNameEdit.setText(project.name);
appNameEdit.setSelection(project.name.length());
appNameEdit.requestFocus();
appNameButton.setVisibility(View.INVISIBLE);
} else {
appNameEdit.setVisibility(View.INVISIBLE);
appNameButton.setVisibility(View.VISIBLE);
//dismissKeyBoard(appNameEdit, false);
}
//appNameEdit.setOnClickListener(appNameClickListener);
TextView flashBtnText = (TextView) convertView.findViewById(R.id.project_item_text);
flashBtnText.setTypeface(MBApp.getApp().getRobotoTypeface());
LinearLayout sendBtnLayout = (LinearLayout) convertView.findViewById(R.id.sendBtn);
sendBtnLayout.setTag(position);
sendBtnLayout.setOnClickListener(sendBtnClickListener);
ImageButton deleteBtn = (ImageButton) convertView.findViewById(R.id.deleteBtn);
deleteBtn.setTag(position);
deleteBtn.setOnClickListener(deleteBtnClickListener);
deleteBtn.setEnabled(true);
Drawable myIcon;
if(project.runStatus) {
flashBtnText.setText("");
myIcon = convertView.getResources().getDrawable(R.drawable.green_btn);
} else {
flashBtnText.setText(R.string.flash);
myIcon = convertView.getResources().getDrawable(R.drawable.blue_btn);
}
sendBtnLayout.setBackground(myIcon);
sendBtnLayout.setClickable(true);
return convertView;
}
示例11: findAllViews
import android.widget.Button; //导入方法依赖的package包/类
private void findAllViews(ViewGroup viewGroup,ArrayList<Integer> ids) {
for (int i = 0, n = viewGroup.getChildCount(); i < n; i++) {
View child = viewGroup.getChildAt(i);
//NAVIGATION VIEW - MENU VIEW
if((viewGroup instanceof NavigationView) && (child instanceof NavigationMenuView)) {
NavigationMenuView nmv = (NavigationMenuView) child;
for (int t = 0, p = nmv.getChildCount(); t < p; t++) {
View childMenu = nmv.getChildAt(t);
if (childMenu instanceof NavigationMenuItemView) {
final NavigationMenuItemView item = (NavigationMenuItemView) childMenu;
_lastTitleMenuItemSelected = item.getItemData().getTitle().toString();
item.setOnLongClickListener(onLongClickListener);
} else if (childMenu instanceof TextView) {
TextView txt = (TextView) childMenu;
makeViewIdElementToSelectableMode(txt);
}
}
//BUTTONS
}else if(child instanceof Button){
Button bt = (Button) child;
_lastTitleMenuItemSelected = bt.getText().toString();
bt.setOnLongClickListener(onLongClickListener);
//ANY OTHER ITEMS
} else if (child instanceof ViewGroup) {
findAllViews((ViewGroup) child, ids);
} else {
if (child instanceof TextView) {
TextView txt2 = (TextView) child;
makeViewIdElementToSelectableMode(txt2);
}
}
}
}