Java Code Examples for android.view.View#setFocusableInTouchMode()
The following examples show how to use
android.view.View#setFocusableInTouchMode() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: zhangshangwuda File: DropPopMenu.java License: Apache License 2.0 | 6 votes |
private void initList() { View popupWindow_view = LayoutInflater.from(context).inflate( R.layout.droppopmenu, null); popupWindow_view.setFocusableInTouchMode(true); // 设置popupWindow的布局 popupWindow = new PopupWindow(popupWindow_view, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT); popupWindow.setTouchable(true); popupWindow.setFocusable(true); // 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景 popupWindow.setBackgroundDrawable(new ColorDrawable( android.R.color.transparent)); // 设置允许在外点击消失 popupWindow.setOutsideTouchable(true); listView = (ListView) popupWindow_view .findViewById(R.id.droppopmenu_listView); popupWindow.update(); }
Example 2
Source Project: arcusandroid File: TextPickerPopup.java License: Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); closeBtn.setOnClickListener(this); if(doneBtn != null) { doneBtn.setOnClickListener(this); } view.setFocusableInTouchMode(true); view.requestFocus(); view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { doClose(); return true; } else { return false; } } }); return view; }
Example 3
Source Project: YCCustomText File: HyperLibUtils.java License: Apache License 2.0 | 6 votes |
/** * 打开软键盘 * @param context 上下文 * @param view view * @param flags flags */ private static void openSoftInput(final Context context, @NonNull final View view, final int flags) { InputMethodManager imm = (InputMethodManager) context.getApplicationContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (imm == null) { return; } view.setFocusable(true); view.setFocusableInTouchMode(true); view.requestFocus(); imm.showSoftInput(view, flags, new ResultReceiver(new Handler()) { @Override protected void onReceiveResult(int resultCode, Bundle resultData) { if (resultCode == InputMethodManager.RESULT_UNCHANGED_HIDDEN || resultCode == InputMethodManager.RESULT_HIDDEN) { toggleSoftInput(context); } } }); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); }
Example 4
Source Project: AndroidFrame File: BasePickerView.java License: Apache License 2.0 | 6 votes |
public void setKeyBackCancelable(boolean isCancelable) { ViewGroup View; if (isDialog()) { View = dialogView; } else { View = rootView; } View.setFocusable(isCancelable); View.setFocusableInTouchMode(isCancelable); if (isCancelable) { View.setOnKeyListener(onKeyBackListener); } else { View.setOnKeyListener(null); } }
Example 5
Source Project: RichEditor File: RichAdapter.java License: Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { int i = v.getId(); if (i == R.id.etv_rich_delete) { int pos = (int) v.getTag(); if (mOnPhotoDelete != null) { mOnPhotoDelete.onDelete(mData.get(pos).source); } mData.remove(pos); index--; notifyDataChanged(); } else if (i == R.id.et_rich_edit) { v.setFocusableInTouchMode(true); v.setFocusable(true); v.requestFocus(); index = (int) v.getTag(); clearImgFocus(index); mData.get(index).curIndex = ((EditText) v).getSelectionStart(); if (mOnEditEvent != null) { mOnEditEvent.onEditClick(index, ((EditText) v).getSelectionStart()); } } }
Example 6
Source Project: TvWidget File: DemoMenuActivity.java License: Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { int pos = (int) v.getTag(); String tip = "click===" + pos; Toast.makeText(mContext, tip, Toast.LENGTH_SHORT).show(); v.setFocusableInTouchMode(true); v.requestFocus(); }
Example 7
Source Project: Android-utils File: ViewUtils.java License: Apache License 2.0 | 5 votes |
public static void showSoftInput(final View view) { InputMethodManager imm = (InputMethodManager) UtilsApp.getApp().getSystemService(Context.INPUT_METHOD_SERVICE); if (imm == null) return; view.setFocusable(true); view.setFocusableInTouchMode(true); view.requestFocus(); imm.showSoftInput(view, InputMethodManager.SHOW_FORCED); }
Example 8
Source Project: Nibo File: NiboPickerFragment.java License: MIT License | 5 votes |
private void setUpBackPresses(View view) { view.setFocusableInTouchMode(true); view.requestFocus(); view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { // handle back button's click listener presenter.handleBackPress(); return true; } return false; } }); }
Example 9
Source Project: FastWaiMai File: BottomItemDelegate.java License: MIT License | 5 votes |
@Override public void onResume() { super.onResume(); final View rootview = getView(); if(rootview != null){ rootview.setFocusableInTouchMode(true); rootview.requestFocus(); //注册Listenner rootview.setOnKeyListener(this); } }
Example 10
Source Project: AcgClub File: KeyboardUtils.java License: MIT License | 5 votes |
/** * Show the soft input. * * @param view The view. */ public static void showSoftInput(final View view) { InputMethodManager imm = (InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE); if (imm == null) { return; } view.setFocusable(true); view.setFocusableInTouchMode(true); view.requestFocus(); imm.showSoftInput(view, InputMethodManager.SHOW_FORCED); }
Example 11
Source Project: financisto File: TransactionInfoDialog.java License: GNU General Public License v2.0 | 5 votes |
private void add(LinearLayout layout, int labelId, String data, String pictureFileName) { View v = inflater.new PictureBuilder(layout) .withPicture(context, pictureFileName) .withLabel(labelId) .withData(data) .create(); v.setClickable(false); v.setFocusable(false); v.setFocusableInTouchMode(false); ImageView pictureView = v.findViewById(R.id.picture); pictureView.setTag(pictureFileName); }
Example 12
Source Project: SuperNote File: RvEditFolderAdapter.java License: GNU General Public License v3.0 | 5 votes |
public void setFoucus(View view){ // 获取 接受焦点的资格 view.setFocusable(true); // 获取 焦点可以响应点触的资格 view.setFocusableInTouchMode(true); // 请求焦点 view.requestFocus(); // 弹出键盘 InputMethodManager manager=(InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); manager.toggleSoftInput(0,0); manager.showSoftInput(view,0); }
Example 13
Source Project: friendly-plans File: TaskListActivity.java License: GNU General Public License v3.0 | 5 votes |
private void showSelectedList(View view, Integer typeId) { view.setFocusableInTouchMode(true); view.requestFocus(); view.setFocusableInTouchMode(false); selectedTypeId = typeId; taskItemList = taskTemplateRepository.getByTypeId(typeId); taskListAdapter.setTaskItems(taskItemList); }
Example 14
Source Project: Androzic File: MapList.java License: GNU General Public License v3.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.list_with_empty_view_and_progressbar, container, false); progressBar = (ProgressBar) view.findViewById(R.id.progressbar); view.setFocusableInTouchMode(true); view.requestFocus(); view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { if (currentTree != mapsTree) { currentTree = currentTree.parent; adapter.notifyDataSetChanged(); return true; } } return false; } }); return view; }
Example 15
Source Project: android-test File: ViewMatchersTest.java License: Apache License 2.0 | 5 votes |
@Test public void isFocusedTest() { View focused = new View(context); focused.setFocusable(true); focused.setFocusableInTouchMode(true); focused.requestFocus(); View notFocused = new View(context); assertTrue(focused.isFocused()); assertTrue(isFocused().matches(focused)); assertFalse(isFocused().matches(notFocused)); }
Example 16
Source Project: XKnife-Android File: KeyboardUtils.java License: Apache License 2.0 | 5 votes |
/** * 弹出软键盘 * * @param view the view */ public static void showKeyboard(final View view) { view.setFocusable(true); view.setFocusableInTouchMode(true); view.requestFocus(); view.postDelayed(new Runnable() { @Override public void run() { InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE); imm.showSoftInput(view, InputMethodManager.RESULT_UNCHANGED_SHOWN); } }, 400); }
Example 17
Source Project: LaunchEnr File: LauncherAppWidgetHostView.java License: GNU General Public License v3.0 | 5 votes |
@Override public void requestChildFocus(View child, View focused) { super.requestChildFocus(child, focused); dispatchChildFocus(mChildrenFocused && focused != null); if (focused != null) { focused.setFocusableInTouchMode(false); } }
Example 18
Source Project: MVVMArms File: KeyboardUtils.java License: Apache License 2.0 | 5 votes |
/** * 动态显示软键盘 * * @param view 视图 */ public static void showSoftInput(Context context, final View view) { view.setFocusable(true); view.setFocusableInTouchMode(true); view.requestFocus(); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm == null) { return; } imm.showSoftInput(view, InputMethodManager.SHOW_FORCED); }
Example 19
Source Project: Onosendai File: TweetListFragment.java License: Apache License 2.0 | 4 votes |
@Override public View onCreateView (final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { this.columnId = getArguments().getInt(ARG_COLUMN_ID); this.columnPosition = getArguments().getInt(ARG_COLUMN_POSITION); this.isLaterColumn = getArguments().getBoolean(ARG_COLUMN_IS_LATER, false); this.inlineMediaStyle = InlineMediaStyle.parseJson(getArguments().getString(ARG_COLUMN_SHOW_INLINEMEDIA)); this.showFiltered = getArguments().getBoolean(ARG_SHOW_FILTERED, false); this.log.setPrefix("C" + this.columnId); this.log.d("onCreateView()"); this.mainActivity = (MainActivity) getActivity(); this.conf = this.mainActivity.getConf(); this.friendlyDateTimeFormat = new FriendlyDateTimeFormat(this.mainActivity); this.imageLoader = ImageLoaderUtils.fromActivity(getActivity()); this.tweetLoader = new LinkedTweetLoader(this.mainActivity, getLocalEs(), getNetEs(), getExecutorEventListener(), this.conf, this.mainActivity, getColumn().isHdMedia()); /* * Fragment life cycles are strange. onCreateView() is called multiple * times before onSaveInstanceState() is called. Do not overwrite * perfectly good stated stored in member var. */ if (this.scrollState == null) { this.scrollState = ScrollState.fromBundle(savedInstanceState); } final View rootView = inflater.inflate(R.layout.tweetlist, container, false); this.sidebar = (SidebarLayout) rootView.findViewById(R.id.tweetListLayout); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new SidebarLayout.BackButtonListener(this.sidebar)); updateScrollLabelToIdle(); this.tweetListEmptyRefresh = (Button) rootView.findViewById(R.id.tweetListEmptyRefresh); this.tweetListEmptyRefresh.setOnClickListener(this.refreshClickListener); this.tweetListSwiper = (SwipeRefreshLayout) rootView.findViewById(R.id.tweetListListSwiper); this.tweetList = (ListView) rootView.findViewById(R.id.tweetListList); this.adapter = new TweetListCursorAdapter(container.getContext(), this.inlineMediaStyle, this.imageLoader, this.tweetLoader, this.tweetList); this.tweetList.setAdapter(this.adapter); this.tweetList.setOnItemClickListener(this.tweetItemClickedListener); this.tweetList.setEmptyView(this.tweetListEmptyRefresh); if (this.inlineMediaStyle == InlineMediaStyle.SEAMLESS) this.tweetList.setDrawSelectorOnTop(true); this.refreshUiHandler = new RefreshUiHandler(this); final ListView lstTweetPayload = (ListView) rootView.findViewById(R.id.tweetDetailPayloadList); this.lstTweetPayloadAdaptor = new PayloadListAdapter(container.getContext(), this.imageLoader, lstTweetPayload, this.payloadClickListener); lstTweetPayload.setAdapter(this.lstTweetPayloadAdaptor); final PayloadListClickListener payloadListClickListener = new PayloadListClickListener(this.payloadClickListener); lstTweetPayload.setOnItemClickListener(payloadListClickListener); lstTweetPayload.setOnItemLongClickListener(payloadListClickListener); ((Button) rootView.findViewById(R.id.tweetDetailClose)).setOnClickListener(new SidebarLayout.ToggleSidebarListener(this.sidebar)); this.btnDetailsLater = (Button) rootView.findViewById(R.id.tweetDetailLater); this.scrollIndicator = ScrollIndicator.attach(getActivity(), (ViewGroup) rootView.findViewById(R.id.tweetListView), this.tweetList, this.tweetListScrollListener); this.tweetListSwiper.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh () { if (!getMainActivity().scheduleRefreshInteractive(getColumnId())) { TweetListFragment.this.tweetListSwiper.setRefreshing(false); } } }); this.tweetListStatus = (TextView) rootView.findViewById(R.id.tweetListStatus); this.tweetListStatus.setOnClickListener(this.tweetListStatusClickListener); return rootView; }
Example 20
Source Project: GiraffePlayer2 File: DefaultMediaController.java License: Apache License 2.0 | 4 votes |
@Override protected void initView(View view) { seekBar = $.id(R.id.app_video_seekBar).view(); seekBar.setMax(1000); seekBar.setOnSeekBarChangeListener(seekListener); $.id(R.id.app_video_play).clicked(onClickListener).imageView().setRotation(isRtl()?180:0); $.id(R.id.app_video_fullscreen).clicked(onClickListener); $.id(R.id.app_video_finish).clicked(onClickListener).imageView().setRotation(isRtl()?180:0); $.id(R.id.app_video_replay_icon).clicked(onClickListener).imageView().setRotation(isRtl()?180:0); $.id(R.id.app_video_clarity).clicked(onClickListener); $.id(R.id.app_video_float_close).clicked(onClickListener); $.id(R.id.app_video_float_full).clicked(onClickListener); final GestureDetector gestureDetector = new GestureDetector(context, createGestureListener()); view.setFocusable(true); view.setFocusableInTouchMode(true); view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (displayModel == GiraffePlayer.DISPLAY_FLOAT) { return false; } if (gestureDetector.onTouchEvent(event)) { return true; } // 处理手势结束 switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_OUTSIDE: endGesture(); break; } return true; } }); }