Java Code Examples for android.widget.ImageButton#setOnTouchListener()
The following examples show how to use
android.widget.ImageButton#setOnTouchListener() .
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 File: EmptyBackgroundViewTablet.java From delion with Apache License 2.0 | 5 votes |
/** * Creates an on touch listener for the menu button using the given menu handler. * @param menuHandler The menu handler to be used for showing the pop up menu. */ public void setMenuOnTouchListener(final AppMenuHandler menuHandler) { final ImageButton menuBtn = (ImageButton) findViewById(R.id.empty_menu_button); final AppMenuButtonHelper menuPopupButtonHelper = new AppMenuButtonHelper(menuHandler); menuBtn.setOnTouchListener(menuPopupButtonHelper); menuPopupButtonHelper.setOnAppMenuShownListener(new Runnable() { @Override public void run() { RecordUserAction.record("MobileToolbarShowMenu"); } }); }
Example 2
Source File: PadActivity.java From Bluefruit_LE_Connect_Android with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pad); mBleManager = BleManager.getInstance(this); restoreRetainedDataFragment(); // UI mContentView = (ViewGroup) findViewById(R.id.contentView); mBufferTextView = (EditText) findViewById(R.id.bufferTextView); if (mBufferTextView != null) { mBufferTextView.setKeyListener(null); // make it not editable } ImageButton upArrowImageButton = (ImageButton) findViewById(R.id.upArrowImageButton); upArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton leftArrowImageButton = (ImageButton) findViewById(R.id.leftArrowImageButton); leftArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton rightArrowImageButton = (ImageButton) findViewById(R.id.rightArrowImageButton); rightArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton bottomArrowImageButton = (ImageButton) findViewById(R.id.bottomArrowImageButton); bottomArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button1ImageButton = (ImageButton) findViewById(R.id.button1ImageButton); button1ImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button2ImageButton = (ImageButton) findViewById(R.id.button2ImageButton); button2ImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button3ImageButton = (ImageButton) findViewById(R.id.button3ImageButton); button3ImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button4ImageButton = (ImageButton) findViewById(R.id.button4ImageButton); button4ImageButton.setOnTouchListener(mPadButtonTouchListener); // Read shared preferences maxPacketsToPaintAsText = PreferencesFragment.getUartTextMaxPackets(this); //Log.d(TAG, "maxPacketsToPaintAsText: "+maxPacketsToPaintAsText); // Start services onServicesDiscovered(); }
Example 3
Source File: EmptyBackgroundViewTablet.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Creates an on touch listener for the menu button using the given menu handler. * @param menuHandler The menu handler to be used for showing the pop up menu. */ public void setMenuOnTouchListener(final AppMenuHandler menuHandler) { final ImageButton menuBtn = (ImageButton) findViewById(R.id.empty_menu_button); final AppMenuButtonHelper menuPopupButtonHelper = new AppMenuButtonHelper(menuHandler); menuBtn.setOnTouchListener(menuPopupButtonHelper); menuPopupButtonHelper.setOnAppMenuShownListener(new Runnable() { @Override public void run() { RecordUserAction.record("MobileToolbarShowMenu"); } }); }
Example 4
Source File: NoEditableLayerToolGroup.java From geopaparazzi with GNU General Public License v3.0 | 5 votes |
public void initUI() { LinearLayout parent = EditManager.INSTANCE.getToolsLayout(); Context context = parent.getContext(); // IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer(); int padding = 2; selectAllButton = new ImageButton(context); selectAllButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_24dp)); selectAllButton.setPadding(0, padding, 0, padding); selectAllButton.setOnClickListener(this); selectAllButton.setOnTouchListener(this); parent.addView(selectAllButton); }
Example 5
Source File: EmptyBackgroundViewTablet.java From 365browser with Apache License 2.0 | 5 votes |
/** * Creates an on touch listener for the menu button using the given menu handler. * @param menuHandler The menu handler to be used for showing the pop up menu. */ public void setMenuOnTouchListener(final AppMenuHandler menuHandler) { final ImageButton menuBtn = (ImageButton) findViewById(R.id.empty_menu_button); final AppMenuButtonHelper menuPopupButtonHelper = new AppMenuButtonHelper(menuHandler); menuBtn.setOnTouchListener(menuPopupButtonHelper); menuPopupButtonHelper.setOnAppMenuShownListener(new Runnable() { @Override public void run() { RecordUserAction.record("MobileToolbarShowMenu"); } }); }
Example 6
Source File: FloatService.java From Float-Bar with Eclipse Public License 1.0 | 5 votes |
private void createFloatView() { wmParams = Util.getParams(wmParams); // 悬浮窗默认显示以左上角为起始坐标 wmParams.gravity = Gravity.RIGHT| Gravity.TOP; if (!prefs.isRightMode()) { wmParams.gravity = Gravity.LEFT | Gravity.TOP; } // 以屏幕右上角为原点,设置x、y初始值,确定显示窗口的起始位置 wmParams.x = 0; wmParams.y = 0; mWindowManager = (WindowManager) service.getSystemService(Context.WINDOW_SERVICE); LayoutInflater inflater = LayoutInflater.from(service); // 获取浮动窗口视图所在布局 mFloatLayout = (LinearLayout) inflater.inflate(R.layout.floating, null); // 添加悬浮窗的视图 mWindowManager.addView(mFloatLayout, wmParams); /** * 设置悬浮窗的点击、滑动事件 */ sampleFloat = (ImageButton) mFloatLayout.findViewById(R.id.float_button_id); sampleFloat.getBackground().setAlpha(150); sampleFloat.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { prefs.doTouch(service); } }); /** * 设置有无反馈 */ MyOnGestureListener listener = new MyOnGestureListener(); @SuppressWarnings("deprecation") final GestureDetector mGestureDetector = new GestureDetector(listener); sampleFloat.setOnTouchListener(new MyOnTouchListener(mGestureDetector)); }
Example 7
Source File: KeypadFragment.java From restcomm-android-sdk with GNU Affero General Public License v3.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.i(TAG, "%% onCreateView"); controlView = inflater.inflate(R.layout.fragment_keypad, container, false); btnOne = (ImageButton) controlView.findViewById(R.id.imageButton_1); btnOne.setOnTouchListener(this); btnTwo = (ImageButton) controlView.findViewById(R.id.imageButton_2); btnTwo.setOnTouchListener(this); btnThree = (ImageButton) controlView.findViewById(R.id.imageButton_3); btnThree.setOnTouchListener(this); btnFour = (ImageButton) controlView.findViewById(R.id.imageButton_4); btnFour.setOnTouchListener(this); btnFive = (ImageButton) controlView.findViewById(R.id.imageButton_5); btnFive.setOnTouchListener(this); btnSix = (ImageButton) controlView.findViewById(R.id.imageButton_6); btnSix.setOnTouchListener(this); btnSeven = (ImageButton) controlView.findViewById(R.id.imageButton_7); btnSeven.setOnTouchListener(this); btnEight = (ImageButton) controlView.findViewById(R.id.imageButton_8); btnEight.setOnTouchListener(this); btnNine = (ImageButton) controlView.findViewById(R.id.imageButton_9); btnNine.setOnTouchListener(this); btnZero = (ImageButton) controlView.findViewById(R.id.imageButton_0); btnZero.setOnTouchListener(this); btnStar = (ImageButton) controlView.findViewById(R.id.imageButton_star); btnStar.setOnTouchListener(this); btnHash = (ImageButton) controlView.findViewById(R.id.imageButton_hash); btnHash.setOnTouchListener(this); btnCancel = (ImageButton) controlView.findViewById(R.id.button_cancel); btnCancel.setOnTouchListener(this); backgroundView = (ImageView)controlView.findViewById(R.id.backgroundView); // Inflate the layout for this fragment return controlView; }
Example 8
Source File: LineCreateFeatureToolGroup.java From geopaparazzi with GNU General Public License v3.0 | 4 votes |
public void initUI() { LinearLayout parent = EditManager.INSTANCE.getToolsLayout(); parent.removeAllViews(); Context context = parent.getContext(); IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer(); int padding = 2; if (editLayer != null) { gpsStreamButton = new ImageButton(context); gpsStreamButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); gpsStreamButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_gps_stream_24dp)); gpsStreamButton.setPadding(0, padding, 0, padding); gpsStreamButton.setOnTouchListener(this); gpsStreamButton.setOnLongClickListener(this); gpsStreamButton.setOnClickListener(this); parent.addView(gpsStreamButton); addVertexButton = new ImageButton(context); addVertexButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); addVertexButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_vertex_24dp)); addVertexButton.setPadding(0, padding, 0, padding); addVertexButton.setOnTouchListener(this); addVertexButton.setOnClickListener(this); parent.addView(addVertexButton); addVertexByTapButton = new ImageButton(context); addVertexByTapButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); addVertexByTapButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_vertex_tap_24dp)); addVertexByTapButton.setPadding(0, padding, 0, padding); addVertexByTapButton.setOnTouchListener(this); addVertexByTapButton.setOnClickListener(this); parent.addView(addVertexByTapButton); undoButton = new ImageButton(context); undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp)); undoButton.setPadding(0, padding, 0, padding); undoButton.setOnTouchListener(this); undoButton.setOnClickListener(this); parent.addView(undoButton); commitButton = new ImageButton(context); commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp)); commitButton.setPadding(0, padding, 0, padding); commitButton.setOnTouchListener(this); commitButton.setOnClickListener(this); commitButton.setVisibility(View.GONE); parent.addView(commitButton); } }
Example 9
Source File: ControllerPadFragment.java From Bluefruit_LE_Connect_Android_V2 with MIT License | 4 votes |
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // Set title AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(R.string.controlpad_title); actionBar.setDisplayHomeAsUpEnabled(true); } } // UI mRootLayout = view.findViewById(R.id.rootLayout); mTopSpacerView = view.findViewById(R.id.topSpacerView); mBottomSpacerView = view.findViewById(R.id.bottomSpacerView); mContentView = view.findViewById(R.id.contentView); mBufferTextView = view.findViewById(R.id.bufferTextView); if (mBufferTextView != null) { mBufferTextView.setKeyListener(null); // make it not editable } ImageButton upArrowImageButton = view.findViewById(R.id.upArrowImageButton); upArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton leftArrowImageButton = view.findViewById(R.id.leftArrowImageButton); leftArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton rightArrowImageButton = view.findViewById(R.id.rightArrowImageButton); rightArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton bottomArrowImageButton = view.findViewById(R.id.bottomArrowImageButton); bottomArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button1ImageButton = view.findViewById(R.id.button1ImageButton); button1ImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button2ImageButton = view.findViewById(R.id.button2ImageButton); button2ImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button3ImageButton = view.findViewById(R.id.button3ImageButton); button3ImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button4ImageButton = view.findViewById(R.id.button4ImageButton); button4ImageButton.setOnTouchListener(mPadButtonTouchListener); // Read shared preferences maxPacketsToPaintAsText = UartBaseFragment.kDefaultMaxPacketsToPaintAsText; //PreferencesFragment.getUartTextMaxPackets(this); }
Example 10
Source File: PointOnSelectionToolGroup.java From geopaparazzi with GNU General Public License v3.0 | 4 votes |
public void initUI() { LinearLayout parent = EditManager.INSTANCE.getToolsLayout(); parent.removeAllViews(); Context context = parent.getContext(); IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer(); int padding = 2; if (editLayer != null) { deleteFeatureButton = new ImageButton(context); deleteFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); deleteFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_delete_point_feature_24dp)); deleteFeatureButton.setPadding(0, padding, 0, padding); deleteFeatureButton.setOnTouchListener(this); deleteFeatureButton.setOnClickListener(this); parent.addView(deleteFeatureButton); // copyFeatureButton = new ImageButton(context); // copyFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, // LayoutParams.WRAP_CONTENT)); // copyFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_copy_geoms_24dp)); // copyFeatureButton.setPadding(0, padding, 0, padding); // copyFeatureButton.setOnTouchListener(this); // copyFeatureButton.setOnClickListener(this); // parent.addView(copyFeatureButton); editAttributesButton = new ImageButton(context); editAttributesButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); editAttributesButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_view_attributes_24dp)); editAttributesButton.setPadding(0, padding, 0, padding); editAttributesButton.setOnTouchListener(this); editAttributesButton.setOnClickListener(this); parent.addView(editAttributesButton); undoButton = new ImageButton(context); undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp)); undoButton.setPadding(0, padding, 0, padding); undoButton.setOnTouchListener(this); undoButton.setOnClickListener(this); parent.addView(undoButton); commitButton = new ImageButton(context); commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp)); commitButton.setPadding(0, padding, 0, padding); commitButton.setOnTouchListener(this); commitButton.setOnClickListener(this); parent.addView(commitButton); commitButton.setVisibility(View.GONE); } }
Example 11
Source File: PointCreateFeatureToolGroup.java From geopaparazzi with GNU General Public License v3.0 | 4 votes |
public void initUI() { LinearLayout parent = EditManager.INSTANCE.getToolsLayout(); parent.removeAllViews(); Context context = parent.getContext(); IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer(); int padding = 2; if (editLayer != null) { gpsStreamButton = new ImageButton(context); gpsStreamButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); gpsStreamButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_gps_off_24dp)); gpsStreamButton.setPadding(0, padding, 0, padding); gpsStreamButton.setOnTouchListener(this); gpsStreamButton.setOnLongClickListener(this); gpsStreamButton.setOnClickListener(this); parent.addView(gpsStreamButton); addVertexButton = new ImageButton(context); addVertexButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); addVertexButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_center_24dp)); addVertexButton.setPadding(0, padding, 0, padding); addVertexButton.setOnTouchListener(this); addVertexButton.setOnClickListener(this); parent.addView(addVertexButton); addVertexByTapButton = new ImageButton(context); addVertexByTapButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); addVertexByTapButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_tap_off_24dp)); addVertexByTapButton.setPadding(0, padding, 0, padding); addVertexByTapButton.setOnTouchListener(this); addVertexByTapButton.setOnClickListener(this); parent.addView(addVertexByTapButton); undoButton = new ImageButton(context); undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp)); undoButton.setPadding(0, padding, 0, padding); undoButton.setOnTouchListener(this); undoButton.setOnClickListener(this); parent.addView(undoButton); commitButton = new ImageButton(context); commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp)); commitButton.setPadding(0, padding, 0, padding); commitButton.setOnTouchListener(this); commitButton.setOnClickListener(this); commitButton.setVisibility(View.GONE); parent.addView(commitButton); } }
Example 12
Source File: LineOnSelectionToolGroup.java From geopaparazzi with GNU General Public License v3.0 | 4 votes |
public void initUI() { LinearLayout parent = EditManager.INSTANCE.getToolsLayout(); parent.removeAllViews(); Context context = parent.getContext(); IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer(); int padding = 2; if (editLayer != null) { deleteFeatureButton = new ImageButton(context); deleteFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); deleteFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_delete_line_feature_24dp)); deleteFeatureButton.setPadding(0, padding, 0, padding); deleteFeatureButton.setOnTouchListener(this); deleteFeatureButton.setOnClickListener(this); parent.addView(deleteFeatureButton); // copyFeatureButton = new ImageButton(context); // copyFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, // LayoutParams.WRAP_CONTENT)); // copyFeatureButton.setBackground(context.getDrawable(R.drawable.editing_copy_geoms)); // copyFeatureButton.setPadding(0, padding, 0, padding); // copyFeatureButton.setOnTouchListener(this); // copyFeatureButton.setOnClickListener(this); // parent.addView(copyFeatureButton); continueLineFeatureButton = new ImageButton(context); continueLineFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); continueLineFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_continue_line_24dp)); continueLineFeatureButton.setPadding(0, padding, 0, padding); continueLineFeatureButton.setOnClickListener(this); continueLineFeatureButton.setOnTouchListener(this); parent.addView(continueLineFeatureButton); editAttributesButton = new ImageButton(context); editAttributesButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); editAttributesButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_view_attributes_24dp)); editAttributesButton.setPadding(0, padding, 0, padding); editAttributesButton.setOnTouchListener(this); editAttributesButton.setOnClickListener(this); parent.addView(editAttributesButton); undoButton = new ImageButton(context); undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp)); undoButton.setPadding(0, padding, 0, padding); undoButton.setOnTouchListener(this); undoButton.setOnClickListener(this); parent.addView(undoButton); commitButton = new ImageButton(context); commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp)); commitButton.setPadding(0, padding, 0, padding); commitButton.setOnTouchListener(this); commitButton.setOnClickListener(this); parent.addView(commitButton); commitButton.setVisibility(View.GONE); } }
Example 13
Source File: PolygonOnSelectionToolGroup.java From geopaparazzi with GNU General Public License v3.0 | 4 votes |
public void initUI() { LinearLayout parent = EditManager.INSTANCE.getToolsLayout(); parent.removeAllViews(); Context context = parent.getContext(); IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer(); int padding = 2; if (editLayer != null) { deleteFeatureButton = new ImageButton(context); deleteFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); deleteFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_delete_feature_24dp)); deleteFeatureButton.setPadding(0, padding, 0, padding); deleteFeatureButton.setOnTouchListener(this); deleteFeatureButton.setOnClickListener(this); parent.addView(deleteFeatureButton); // copyFeatureButton = new ImageButton(context); // copyFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, // LayoutParams.WRAP_CONTENT)); // copyFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_copy_geoms_24dp)); // copyFeatureButton.setPadding(0, padding, 0, padding); // copyFeatureButton.setOnTouchListener(this); // copyFeatureButton.setOnClickListener(this); // parent.addView(copyFeatureButton); editAttributesButton = new ImageButton(context); editAttributesButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); editAttributesButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_view_attributes_24dp)); editAttributesButton.setPadding(0, padding, 0, padding); editAttributesButton.setOnTouchListener(this); editAttributesButton.setOnClickListener(this); parent.addView(editAttributesButton); undoButton = new ImageButton(context); undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp)); undoButton.setPadding(0, padding, 0, padding); undoButton.setOnTouchListener(this); undoButton.setOnClickListener(this); parent.addView(undoButton); commitButton = new ImageButton(context); commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp)); commitButton.setPadding(0, padding, 0, padding); commitButton.setOnTouchListener(this); commitButton.setOnClickListener(this); parent.addView(commitButton); commitButton.setVisibility(View.GONE); } }
Example 14
Source File: LineMainEditingToolGroup.java From geopaparazzi with GNU General Public License v3.0 | 4 votes |
public void initUI() { LinearLayout parent = EditManager.INSTANCE.getToolsLayout(); Context context = parent.getContext(); IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer(); int padding = 2; if (editLayer != null) { createFeatureButton = new ImageButton(context); createFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); createFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_create_line_24dp)); createFeatureButton.setPadding(0, padding, 0, padding); createFeatureButton.setOnClickListener(this); createFeatureButton.setOnTouchListener(this); parent.addView(createFeatureButton); selectEditableButton = new ImageButton(context); selectEditableButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); selectEditableButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_editable_24dp)); selectEditableButton.setPadding(0, padding, 0, padding); selectEditableButton.setOnClickListener(this); selectEditableButton.setOnTouchListener(this); parent.addView(selectEditableButton); } selectAllButton = new ImageButton(context); selectAllButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); Tool activeTool = EditManager.INSTANCE.getActiveTool(); if (activeTool instanceof InfoTool) { selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_active_24dp)); } else { selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_24dp)); } selectAllButton.setPadding(0, padding, 0, padding); selectAllButton.setOnClickListener(this); selectAllButton.setOnTouchListener(this); parent.addView(selectAllButton); if (editLayer != null) { undoButton = new ImageButton(context); undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp)); undoButton.setPadding(0, padding, 0, padding); undoButton.setOnTouchListener(this); undoButton.setOnClickListener(this); parent.addView(undoButton); undoButton.setVisibility(View.GONE); commitButton = new ImageButton(context); commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp)); commitButton.setPadding(0, padding, 0, padding); commitButton.setOnTouchListener(this); commitButton.setOnClickListener(this); parent.addView(commitButton); commitButton.setVisibility(View.GONE); } }
Example 15
Source File: MeasurementActivity.java From NoiseCapture with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if(checkAndAskPermissions()) { // Application have right now all permissions doBindService(); } setContentView(R.layout.activity_measurement); initDrawer(); // Check if the dialog box (for caution) must be displayed // Depending of the settings SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); sharedPref.registerOnSharedPreferenceChangeListener(this); Boolean CheckNbRunSettings = sharedPref.getBoolean("settings_caution", true); hasMaximalMeasurementTime = sharedPref.getBoolean(HAS_MAXIMAL_MEASURE_TIME_SETTING, false); maximalMeasurementTime = getInteger(sharedPref, MAXIMAL_MEASURE_TIME_SETTING, DEFAULT_MAXIMAL_MEASURE_TIME_SETTING); if (CheckNbRunSettings && CheckNbRun("NbRunMaxCaution", getResources().getInteger(R.integer .NbRunMaxCaution))) { new AlertDialog.Builder(this).setTitle(R.string.title_caution) .setMessage(R.string.text_caution) .setNeutralButton(R.string.text_OK, null) .setIcon(android.R.drawable.ic_dialog_alert) .show(); } // Enabled/disabled buttons buttonPause = (ImageButton) findViewById(R.id.pauseBtn); buttonPause.setEnabled(false); // To start a record (test mode) buttonrecord = (ImageButton) findViewById(R.id.recordBtn); buttonrecord.setImageResource(R.drawable.button_record_normal); buttonrecord.setEnabled(true); // Actions on record button doProcessing = new DoProcessing(this); buttonrecord.setOnClickListener(doProcessing); // Action on cancel button (during recording) buttonPause.setOnClickListener(onButtonPause); buttonPause.setOnTouchListener(new ToggleButtonTouch(this)); // Init tabs (Spectrum, Spectrogram, Map) viewPager = (ViewPagerExt) findViewById(R.id.measurement_viewpager); setupViewPager(viewPager); TabLayout tabLayout = (TabLayout) findViewById(R.id.measurement_tabs); tabLayout.setupWithViewPager(viewPager); // Select map by default viewPager.setCurrentItem(2); // Instantaneous sound level VUMETER // Stacked bars are used for represented Min, Current and Max values // Horizontal barchart LinearLayout graphLayouts = (LinearLayout) findViewById(R.id.graph_components_layout); mChart = (HorizontalBarChart) findViewById(R.id.vumeter); mChart.setTouchEnabled(false); initVueMeter(); setData(0); // Legend: hide all Legend lv = mChart.getLegend(); lv.setEnabled(false); // Hide legend }
Example 16
Source File: MainActivity.java From sensordatacollector with GNU General Public License v2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { // init super.onCreate(savedInstanceState); setContentView(R.layout.round_activity_main); this.onDestroyResume = true; this.sl = new ScreenListener(); String deviceID = DeviceID.get(this); // start sensor service startService(new Intent(MainActivity.this, SensorService.class)); // observe screen startObserveScreen(); // keep screen on // getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // register activity ActivityController.getInstance().add("MainActivity", this); // inform mobile phone BroadcastService.initInstance(this); BroadcastService.getInstance().getAPIClient().connect(); if(BluetoothAdapter.getDefaultAdapter() != null) { BroadcastService.getInstance().sendMessage("/activity/started", deviceID + "~#X*X#~" + BluetoothAdapter.getDefaultAdapter().getAddress()); } // set up layout final ImageButton button = (ImageButton) findViewById(R.id.welcome_button_continue); button.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { button.setOnTouchListener(null); createMainView(); return true; } }); }
Example 17
Source File: LogInActivity.java From PracticeCode with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { //动态从域名获取IP XSCHelper.getInstance().refreshIPbyHost(); //初始化 super.onCreate(savedInstanceState); setContentView(R.layout.activity_log_in); //获取组件实例 icon = (ImageView) findViewById(R.id.iconView); nameEdit = (EditText) findViewById(R.id.nameEdit); pswEdit = (EditText) findViewById(R.id.pswEdit); logIn = (ImageButton) findViewById(R.id.loginButton); initAnimation(); //获取本地化数据,自动填充已有用户名,密码。设置焦点 final SharedPreferences preferences = this.getPreferences(MODE_PRIVATE); nameEdit.setText(preferences.getString("savedAccount", "")); if (!nameEdit.getText().toString().equals("")) { pswEdit.requestFocus(); } pswEdit.setNextFocusDownId(R.id.loginButton); //登陆按钮监听(设置变色,登陆) logIn.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) view.setBackgroundResource(R.drawable.enter_button_hover); else { view.setBackgroundResource(R.drawable.enter_button); //获取文本域内容 String name = nameEdit.getText().toString(); String psw = pswEdit.getText().toString(); //本地化存储。优化用户体验 preferences.edit().putString("savedAccount", name).apply(); //收起小桌板 - 3 - SysUtil.getInstance().hideInputKeyboard(LogInActivity.this, view); //如果输入内容不为空,载入动画,登陆 if (!name.equals("") && !psw.equals("")) { XSCHelper.getInstance().logIn(name, psw, handle); LogInAnimationSet(); } } return false; } }); //注册按钮监听 icon.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { icon.setVisibility(View.INVISIBLE); nameEdit.setVisibility(View.INVISIBLE); pswEdit.setVisibility(View.INVISIBLE); logIn.setVisibility(View.INVISIBLE); Intent intent = new Intent(LogInActivity.this, RegisterActivity.class); startActivity(intent); return false; } }); }
Example 18
Source File: EmojiPalettesView.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 4 votes |
@Override protected void onFinishInflate() { mTabHost = (TabHost)findViewById(R.id.emoji_category_tabhost); mTabHost.setup(); for (final EmojiCategory.CategoryProperties properties : mEmojiCategory.getShownCategories()) { addTab(mTabHost, properties.mCategoryId); } mTabHost.setOnTabChangedListener(this); final TabWidget tabWidget = mTabHost.getTabWidget(); tabWidget.setStripEnabled(mCategoryIndicatorEnabled); if (mCategoryIndicatorEnabled) { // On TabWidget's strip, what looks like an indicator is actually a background. // And what looks like a background are actually left and right drawables. tabWidget.setBackgroundResource(mCategoryIndicatorDrawableResId); tabWidget.setLeftStripDrawable(mCategoryIndicatorBackgroundResId); tabWidget.setRightStripDrawable(mCategoryIndicatorBackgroundResId); } mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, this); mEmojiPager = (ViewPager)findViewById(R.id.emoji_keyboard_pager); mEmojiPager.setAdapter(mEmojiPalettesAdapter); mEmojiPager.setOnPageChangeListener(this); mEmojiPager.setOffscreenPageLimit(0); mEmojiPager.setPersistentDrawingCache(PERSISTENT_NO_CACHE); mEmojiLayoutParams.setPagerProperties(mEmojiPager); mEmojiCategoryPageIndicatorView = (EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view); mEmojiCategoryPageIndicatorView.setColors( mCategoryPageIndicatorColor, mCategoryPageIndicatorBackground); mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView); setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */); final LinearLayout actionBar = (LinearLayout)findViewById(R.id.emoji_action_bar); mEmojiLayoutParams.setActionBarProperties(actionBar); // deleteKey depends only on OnTouchListener. mDeleteKey = (ImageButton)findViewById(R.id.emoji_keyboard_delete); mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId); mDeleteKey.setTag(Constants.CODE_DELETE); mDeleteKey.setOnTouchListener(mDeleteKeyOnTouchListener); // {@link #mAlphabetKeyLeft}, {@link #mAlphabetKeyRight, and spaceKey depend on // {@link View.OnClickListener} as well as {@link View.OnTouchListener}. // {@link View.OnTouchListener} is used as the trigger of key-press, while // {@link View.OnClickListener} is used as the trigger of key-release which does not occur // if the event is canceled by moving off the finger from the view. // The text on alphabet keys are set at // {@link #startEmojiPalettes(String,int,float,Typeface)}. mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left); mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId); mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI); mAlphabetKeyLeft.setOnTouchListener(this); mAlphabetKeyLeft.setOnClickListener(this); mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right); mAlphabetKeyRight.setBackgroundResource(mFunctionalKeyBackgroundId); mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI); mAlphabetKeyRight.setOnTouchListener(this); mAlphabetKeyRight.setOnClickListener(this); mSpacebar = findViewById(R.id.emoji_keyboard_space); mSpacebar.setBackgroundResource(mSpacebarBackgroundId); mSpacebar.setTag(Constants.CODE_SPACE); mSpacebar.setOnTouchListener(this); mSpacebar.setOnClickListener(this); mEmojiLayoutParams.setKeyProperties(mSpacebar); mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon); }
Example 19
Source File: PointMainEditingToolGroup.java From geopaparazzi with GNU General Public License v3.0 | 4 votes |
public void initUI() { LinearLayout parent = EditManager.INSTANCE.getToolsLayout(); Context context = parent.getContext(); IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer(); int padding = 2; if (editLayer != null) { createFeatureButton = new ImageButton(context); createFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); createFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_24dp)); createFeatureButton.setPadding(0, padding, 0, padding); createFeatureButton.setOnClickListener(this); createFeatureButton.setOnTouchListener(this); parent.addView(createFeatureButton); selectEditableButton = new ImageButton(context); selectEditableButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); selectEditableButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_editable_24dp)); selectEditableButton.setPadding(0, padding, 0, padding); selectEditableButton.setOnClickListener(this); selectEditableButton.setOnTouchListener(this); parent.addView(selectEditableButton); } selectAllButton = new ImageButton(context); selectAllButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); Tool activeTool = EditManager.INSTANCE.getActiveTool(); if (activeTool instanceof InfoTool) { selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_active_24dp)); } else { selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_24dp)); } selectAllButton.setPadding(0, padding, 0, padding); selectAllButton.setOnClickListener(this); selectAllButton.setOnTouchListener(this); parent.addView(selectAllButton); if (editLayer != null) { undoButton = new ImageButton(context); undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp)); undoButton.setPadding(0, padding, 0, padding); undoButton.setOnTouchListener(this); undoButton.setOnClickListener(this); parent.addView(undoButton); undoButton.setVisibility(View.GONE); commitButton = new ImageButton(context); commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp)); commitButton.setPadding(0, padding, 0, padding); commitButton.setOnTouchListener(this); commitButton.setOnClickListener(this); parent.addView(commitButton); commitButton.setVisibility(View.GONE); } }
Example 20
Source File: MainActivity.java From android-ir-remote with MIT License | 2 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); IRMessages.initialize(); setContentView(R.layout.main_activity); getSupportActionBar().hide(); _vibrator = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); _irController = new IRController(getApplicationContext()); _irController.startWork(); getRowReferences(); _buttonPowerAll = (ImageButton) findViewById(R.id.id_Button_ALL); _button[0] = createIRButton("HDMI HUB",R.drawable.icon_04,_rows[0], new IRMessageRequest(IRMessages.HDMI_SPLITTER_ON)); _button[1] = createIRButton("LG TV",R.drawable.icon_01,_rows[0],new IRMessageRequest(IRMessages.HOME_LG_TV_ON)); _button[2] = createIRButton("HOME THEATER",R.drawable.icon_03,_rows[0],new IRMessageRequest(IRMessages.HOME_SONY_HT_ON)); _button[3] = createIRButton("HDMI 1",R.drawable.icon_09,_rows[1],new IRMessageRequest(IRMessages.HDMI_SPLITTER_SET_1)); _button[4] = createIRButton("HDMI 2",R.drawable.icon_09,_rows[1],new IRMessageRequest(IRMessages.HDMI_SPLITTER_SET_2)); _button[5] = createIRButton("HTPC",R.drawable.icon_10,_rows[1],new IRMessageRequest(IRMessages.HDMI_SPLITTER_SET_3)); _button[6] = createIRButton("VOLUME UP",R.drawable.icon_02,_rows[2],new IRMessageRequest(IRMessages.HOME_LG_TV_VOLUME_UP)); _button[7] = createIRButton("CHROMECAST",R.drawable.icon_06,_rows[2],new IRMessageRequest(IRMessages.HDMI_SPLITTER_SET_5)); _button[8] = createIRButton("VOLUME UP",R.drawable.icon_02,_rows[2],new IRMessageRequest(IRMessages.HOME_SONY_HT_VOLUME_UP)); _button[9] = createIRButton("VOLUME DOWN",R.drawable.icon_08,_rows[3],new IRMessageRequest(IRMessages.HOME_LG_TV_VOLUME_DOWN)); _button[10] = createIRButton("SWITCH",R.drawable.icon_07,_rows[3],new IRMessageRequest(IRMessages.HDMI_SPLITTER_SET_4)); _button[11] = createIRButton("VOLUME DOWN",R.drawable.icon_08,_rows[3],new IRMessageRequest(IRMessages.HOME_SONY_HT_VOLUME_DOWN)); _lastBurstTime = System.nanoTime(); for(int a=0;a<12;a++) { _button[a].setOnTouchListener(this); } _buttonPowerAll.setOnTouchListener(this); }