android.view.View#setFocusableInTouchMode ( )源码实例Demo

下面列出了android.view.View#setFocusableInTouchMode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: zhangshangwuda   文件: DropPopMenu.java
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();
}
 
源代码2 项目: arcusandroid   文件: TextPickerPopup.java
@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;
}
 
源代码3 项目: YCCustomText   文件: HyperLibUtils.java
/**
 * 打开软键盘
 * @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);
}
 
源代码4 项目: AndroidFrame   文件: BasePickerView.java
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);
        }
    }
 
源代码5 项目: RichEditor   文件: RichAdapter.java
@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());
        }
    }
}
 
源代码6 项目: TvWidget   文件: DemoMenuActivity.java
@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();
}
 
源代码7 项目: Android-utils   文件: ViewUtils.java
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);
}
 
源代码8 项目: Nibo   文件: NiboPickerFragment.java
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;
        }
    });
}
 
源代码9 项目: FastWaiMai   文件: BottomItemDelegate.java
@Override
public void onResume() {
    super.onResume();
    final View rootview = getView();
    if(rootview != null){
        rootview.setFocusableInTouchMode(true);
        rootview.requestFocus();
        //注册Listenner
        rootview.setOnKeyListener(this);
    }
}
 
源代码10 项目: AcgClub   文件: KeyboardUtils.java
/**
 * 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);
}
 
源代码11 项目: financisto   文件: TransactionInfoDialog.java
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);
}
 
源代码12 项目: SuperNote   文件: RvEditFolderAdapter.java
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);
    }
 
源代码13 项目: friendly-plans   文件: TaskListActivity.java
private void showSelectedList(View view, Integer typeId) {
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    view.setFocusableInTouchMode(false);
    selectedTypeId = typeId;
    taskItemList = taskTemplateRepository.getByTypeId(typeId);
    taskListAdapter.setTaskItems(taskItemList);
}
 
源代码14 项目: Androzic   文件: MapList.java
@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;
}
 
源代码15 项目: android-test   文件: ViewMatchersTest.java
@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));
}
 
源代码16 项目: XKnife-Android   文件: KeyboardUtils.java
/**
 * 弹出软键盘
 *
 * @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);
}
 
源代码17 项目: LaunchEnr   文件: LauncherAppWidgetHostView.java
@Override
public void requestChildFocus(View child, View focused) {
    super.requestChildFocus(child, focused);
    dispatchChildFocus(mChildrenFocused && focused != null);
    if (focused != null) {
        focused.setFocusableInTouchMode(false);
    }
}
 
源代码18 项目: MVVMArms   文件: KeyboardUtils.java
/**
 * 动态显示软键盘
 *
 * @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);
}
 
源代码19 项目: Onosendai   文件: TweetListFragment.java
@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;
}
 
源代码20 项目: GiraffePlayer2   文件: DefaultMediaController.java
@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;
        }
    });
}
 
 方法所在类
 同类方法