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


Java OnKeyListener类代码示例

本文整理汇总了Java中android.view.View.OnKeyListener的典型用法代码示例。如果您正苦于以下问题:Java OnKeyListener类的具体用法?Java OnKeyListener怎么用?Java OnKeyListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: addMaskView

import android.view.View.OnKeyListener; //导入依赖的package包/类
private void addMaskView(IBinder token) {
    WindowManager.LayoutParams p = new WindowManager.LayoutParams();
    p.width = WindowManager.LayoutParams.MATCH_PARENT;
    p.height = WindowManager.LayoutParams.MATCH_PARENT;
    p.format = PixelFormat.TRANSLUCENT;
    p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
    p.token = token;
    p.windowAnimations = android.R.style.Animation_Toast;
    maskView = new View(context);
    maskView.setBackgroundColor(0x7f000000);
    maskView.setFitsSystemWindows(false);
    // 华为手机在home建进入后台后,在进入应用,蒙层出现在popupWindow上层,导致界面卡死,
    // 这里新增加按bug返回。
    // initType方法已经解决该问题,但是还是留着这个按back返回功能,防止其他手机出现华为手机类似问题。
    maskView.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                removeMaskView();
                return true;
            }
            return false;
        }
    });
    wm.addView(maskView, p);
}
 
开发者ID:qizhenghao,项目名称:Microsoft_Band,代码行数:27,代码来源:BottomPushPopupWindow.java

示例2: rigistTimeAction

import android.view.View.OnKeyListener; //导入依赖的package包/类
public void rigistTimeAction(final EditText editText,
		final Context context, Date date,
		final OnValidateListener onValidateListener) {
	editText.setOnKeyListener(new OnKeyListener() {
		@Override
		public boolean onKey(View v, int keyCode, KeyEvent event) {
			TimeViewManager.this.validateTimeEditText(editText,
					onValidateListener);
			return false;
		}
	});
	// date = date == null ? new Date() : date;
	editText.setText(TimeUtil.dateToAppStringEx(date));
	// editText.setEnabled(false);
	editText.setOnClickListener(new TimeOnClickListener(editText, context,
			onValidateListener));
}
 
开发者ID:AfirSraftGarrier,项目名称:ACCAndroid,代码行数:18,代码来源:TimeViewManager.java

示例3: onCreate

import android.view.View.OnKeyListener; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_screen);
    context = this.getApplicationContext();

    // TODO(radkokotev) redesign the initialization.
    allBuildings = new DataHolder();
    allBuildings.initialize();
    matchedBuildings = new DataHolder();
    
    final EditText id_field = (EditText)findViewById(R.id.nameOfPlace_field);
    id_field.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                    && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                // If the user pressed ENTER, directly search for the place.
                onFindButtonClick(findViewById(R.id.findOnMapButton));
                return true;
            }
            return false;
        }
    });
}
 
开发者ID:radkokotev,项目名称:glasgow_uni_map,代码行数:26,代码来源:GlaUniActivity.java

示例4: switchUI

import android.view.View.OnKeyListener; //导入依赖的package包/类
private void switchUI() {
	final TextView messageText = (TextView)findViewById(R.id.text_messages);
	final EditText textEntry = (EditText)findViewById(R.id.text_message);
	messageText.setVisibility(View.VISIBLE);
	list.setVisibility(View.GONE);
	textEntry.setEnabled(true);
	textEntry.setOnKeyListener(new OnKeyListener() {
		public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
			if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN) &&
					(keyCode == KeyEvent.KEYCODE_DPAD_CENTER)) {
				sendMessage(socket, textEntry.getText().toString());
				textEntry.setText("");
				return true;
			}
			return false;
		}
	});
}
 
开发者ID:hjgode,项目名称:android-stuff,代码行数:19,代码来源:BluetoothTexting.java

示例5: attachKeyListener

import android.view.View.OnKeyListener; //导入依赖的package包/类
/**
 * Attaches onKey listener to the Button passed as a parameter to the
 * method. If enter key on the keyboard or center key on the keypad is
 * pressed, the value of the parameter passed is checked.
 * 
 * @param button
 *            The button with which the onKeyListener is to be associated.
 * @param buttonFlag
 *            If the value of buttonFlag is 1, the number is set as primary
 *            by calling the setPrimaryNumberAndGiveFeedback method. If the
 *            value of buttonFlag is 2, the email ID is set as primary by
 *            calling the setPrimaryMailAndGiveFeedback method.
 */

void attachKeyListener(final Button button, final int buttonFlag) {
	button.setOnKeyListener(new OnKeyListener() {

		@Override
		public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
			if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
				switch (keyCode) {
				case KeyEvent.KEYCODE_DPAD_CENTER:
				case KeyEvent.KEYCODE_ENTER:
					switch (buttonFlag) {
					case 1:
						setPrimaryNumberAndGiveFeedback();
						break;
					case 2:
						setPrimaryMailAndGiveFeedback();
						break;
					}
					break;
				}
			}
			return false;
		}
	});
}
 
开发者ID:saurabh2590,项目名称:EasyAccess,代码行数:39,代码来源:ContactUpdate.java

示例6: attachKeyListener

import android.view.View.OnKeyListener; //导入依赖的package包/类
/**
 * Attaches onKey listener to the Button passed as a parameter to the
 * method. If enter key on the keyboard or center key on the keypad is
 * pressed, the value of the parameter passed is checked.
 * 
 * @param button
 *            The button with which the onKeyListener is to be associated.
 * @param buttonFlag
 *            If the value of buttonFlag is 1, a call is made to the
 *            specified number or name. If the value of buttonFlag is 2, the
 *            number is saved in the phone's contacts.
 */
void attachKeyListener(Button button, final int buttonFlag) {
	button.setOnKeyListener(new OnKeyListener() {

		@Override
		public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
			if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
				switch (keyCode) {
				case KeyEvent.KEYCODE_DPAD_CENTER:
				case KeyEvent.KEYCODE_ENTER:
					switch (buttonFlag) {
					case 1:
						callContact(inputContacts.getText().toString());
						break;
					case 2:
						saveContact(inputContacts.getText().toString());
						break;
					}
					break;
				}
			}
			return false;
		}
	});
}
 
开发者ID:saurabh2590,项目名称:EasyAccess,代码行数:37,代码来源:ContactsApp.java

示例7: attachKeyListener

import android.view.View.OnKeyListener; //导入依赖的package包/类
/**
 * Attaches onKey listener to the Button passed as a parameter to the
 * method. If enter key on the keyboard or center key on the keypad is
 * pressed, saveAndGiveFeedback method is called.
 * 
 * @param button
 *            The button with which the onKeyListener is to be associated.
 */
void attachKeyListener(final Button button) {
	button.setOnKeyListener(new OnKeyListener() {

		@Override
		public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
			if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
				switch (keyCode) {
				case KeyEvent.KEYCODE_DPAD_CENTER:
				case KeyEvent.KEYCODE_ENTER:
					saveAndGiveFeedback();
					break;
				}
			}
			return false;
		}
	});
}
 
开发者ID:saurabh2590,项目名称:EasyAccess,代码行数:26,代码来源:SaveContact.java

示例8: attachKeyListener

import android.view.View.OnKeyListener; //导入依赖的package包/类
/**
 * Attaches onKeyListener to the button passed as a parameter to the method.
 * The method corresponding to the button on which the enter key of the
 * keyboard or the center key of the keypad is pressed.
 * 
 * @param button
 *            The button with which the onKeyListener is to be associated.
 */
void attachKeyListener(Button button) {
	button.setOnKeyListener(new OnKeyListener() {

		@Override
		public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
			if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
				switch (keyCode) {
				case KeyEvent.KEYCODE_DPAD_CENTER:
				case KeyEvent.KEYCODE_ENTER:
					proceed();
					break;
				}
			}
			return false;
		}
	});
}
 
开发者ID:saurabh2590,项目名称:EasyAccess,代码行数:26,代码来源:TextMessagesComposerRecipientApp.java

示例9: attachKeyListener

import android.view.View.OnKeyListener; //导入依赖的package包/类
/**
 * Attaches onKey listener to the button passed as a parameter to the
 * method. If enter key on the keyboard or center key on the keypad is
 * pressed, sendMessage method is called, which will be used to send the
 * text message to the recipient.
 * 
 * @param button
 *            The button with which the onKey listener is to be associated.
 */
void attachKeyListener(Button button) {
	button.setOnKeyListener(new OnKeyListener() {

		@Override
		public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
			if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
				switch (keyCode) {
				case KeyEvent.KEYCODE_DPAD_CENTER:
				case KeyEvent.KEYCODE_ENTER:
					sendMessage();
					break;
				}
			}
			return false;
		}
	});
}
 
开发者ID:saurabh2590,项目名称:EasyAccess,代码行数:27,代码来源:TextMessagesComposerApp.java

示例10: attachKeyListener

import android.view.View.OnKeyListener; //导入依赖的package包/类
/**
 * Attaches onKey listener to the Button passed as a parameter to the
 * method. If enter key on the keyboard or center key on the keypad is
 * pressed, it resets the text color and the background color of the app to
 * their default values.
 * 
 * @param button
 *            This is an instance of Button
 */
void attachKeyListener(final Button button) {
	button.setOnKeyListener(new OnKeyListener() {

		@Override
		public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
			if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
				switch (keyCode) {
				case KeyEvent.KEYCODE_DPAD_CENTER:
				case KeyEvent.KEYCODE_ENTER:
					reset();
					break;
				}
			}
			return false;
		}
	});
}
 
开发者ID:saurabh2590,项目名称:EasyAccess,代码行数:27,代码来源:SettingsColor.java

示例11: onCreate

import android.view.View.OnKeyListener; //导入依赖的package包/类
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.registerpage);
	EditText passwordField = (EditText) findViewById(R.id.registerPassword2);
	passwordField.setOnKeyListener(new OnKeyListener()
	{
	    public boolean onKey(View v, int keyCode, KeyEvent event)
	    {
	        if (event.getAction() == KeyEvent.ACTION_DOWN)
	        {
	            switch (keyCode)
	            {
	                case KeyEvent.KEYCODE_DPAD_CENTER:
	                case KeyEvent.KEYCODE_ENTER:
	                    registerButtonClicked(v);
	                    return true;
	                default:
	                    break;
	            }
	        }
	        return false;
	    }
	});
	ParseAnalytics.trackAppOpened(getIntent());
}
 
开发者ID:arturf1,项目名称:EatingClub,代码行数:27,代码来源:RegisterPage.java

示例12: onCreate

import android.view.View.OnKeyListener; //导入依赖的package包/类
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.friendpage);
	
	EditText searchField = (EditText) findViewById(R.id.searchFriendField);
	searchField.setOnKeyListener(new OnKeyListener()
	{
	    public boolean onKey(View v, int keyCode, KeyEvent event)
	    {
	        if (event.getAction() == KeyEvent.ACTION_DOWN)
	        {
	            switch (keyCode)
	            {
	                case KeyEvent.KEYCODE_DPAD_CENTER:
	                case KeyEvent.KEYCODE_ENTER:
	                    backButtonClicked(v);
	                    return true;
	                default:
	                    break;
	            }
	        }
	        return false;
	    }
	});
}
 
开发者ID:arturf1,项目名称:EatingClub,代码行数:27,代码来源:FriendPage.java

示例13: buildEditText

import android.view.View.OnKeyListener; //导入依赖的package包/类
/**
 * 构建文本框
 */
protected void buildEditText() {
    RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
    textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
    OnKeyListener keyListener = new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                    && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                navigate(mEditText.getText().toString());
                return true;
            }
            return false;
        }
    };
    mEditText =  createEditText(EDITTEXT_ID, textLayoutParams, true, mUrl,
            InputType.TYPE_TEXT_VARIATION_URI, EditorInfo.IME_ACTION_GO,
            keyListener);
}
 
开发者ID:polyvi,项目名称:openxface-android,代码行数:23,代码来源:XInAppBrowser.java

示例14: createView

import android.view.View.OnKeyListener; //导入依赖的package包/类
public void createView() {
    this.inboxView = ((LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(geLayoutId(), null);
    this.listView = (ExpandableListView) this.inboxView.findViewById(R.id.swipe_side_listview);
    this.listView.setEmptyView(this.inboxView.findViewById(R.id.inbox_empty_view));
    InboxViewManager inboxViewManager = (InboxViewManager) GuiceModule.get().getInstance(InboxViewManager.class);
    this.inboxView.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View view, int i, KeyEvent keyEvent) {
            return false;
        }
    });
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:12,代码来源:InboxViewController.java

示例15: init

import android.view.View.OnKeyListener; //导入依赖的package包/类
private void init(Activity activity, View anchorView) {
    getContentView().setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode != 4) {
                return false;
            }
            MQBasePopupWindow.this.dismiss();
            return true;
        }
    });
    setBackgroundDrawable(new ColorDrawable(0));
    this.mAnchorView = anchorView;
    this.mActivity = activity;
    this.mWindowRootView = activity.getWindow().peekDecorView();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:MQBasePopupWindow.java


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