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


Java ImageButton.setOnTouchListener方法代码示例

本文整理汇总了Java中android.widget.ImageButton.setOnTouchListener方法的典型用法代码示例。如果您正苦于以下问题:Java ImageButton.setOnTouchListener方法的具体用法?Java ImageButton.setOnTouchListener怎么用?Java ImageButton.setOnTouchListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ImageButton的用法示例。


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

示例1: onCreate

import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_alarm_receiver);
    ImageButton stopAlarm = (ImageButton) findViewById(R.id.stop_alarm);
    stopAlarm.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View arg0, MotionEvent arg1) {
            mMediaPlayer.stop();
            finish();
            return false;
        }
    });

    playSound(this, getAlarmUri());
}
 
开发者ID:akshah1997,项目名称:KJSCE-Hackathon,代码行数:21,代码来源:AlarmReceiver.java

示例2: init

import android.widget.ImageButton; //导入方法依赖的package包/类
/**
 * <ImageButton
 android:id="@+id/ancp_poi_list_drap_bar"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="@color/new_line_border"
 android:src="@drawable/bnav_poi_list_drag"
 android:paddingBottom="10dp"
 android:paddingTop="10dp"
 />
 */
private void init(){
    DisplayMetrics metrics=getContext().getResources().getDisplayMetrics();
    density=metrics.density;
    sHeight=metrics.heightPixels;
    minHeight=dp2px(50);
    Log.i(TAG,"sHeight="+sHeight+",minHeight="+50);
    drawBar=new ImageButton(getContext());
    LayoutParams layoutParams=new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
    drawBar.setBackgroundResource(R.color.base_blue_translucent);
    drawBar.setImageResource(R.drawable.bnav_poi_list_drag);
    drawBar.setPadding(0, dp2px(10), 0, dp2px(10));
    addView(drawBar, 0, layoutParams);

    drawBar.setOnTouchListener(drawTouchListener);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:27,代码来源:DrawForExpandLayout.java

示例3: setMenuOnTouchListener

import android.widget.ImageButton; //导入方法依赖的package包/类
/**
 * 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");
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:16,代码来源:EmptyBackgroundViewTablet.java

示例4: RightLeftButtonsBar

import android.widget.ImageButton; //导入方法依赖的package包/类
public RightLeftButtonsBar(Context context, BrailleLayout brailleLayout) {
    super(context);
    try {
        this.context = context;
        this.surfaceContainer = brailleLayout.getBrailleLayoutContainer(context);
        this.brailleLayout = brailleLayout;
        this.vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
        MyAccessibilityEventHandler myAccessibilityEventHandler = new MyAccessibilityEventHandler();
        setOnTouchListener(this);

        //views declarations
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.ops_buttons_right_left, this, true);
        makeKeyboardFullWidth = (ImageButton) view.findViewById(R.id.makeKeyboardFullWidth);
        moveKeyboardRightLeft = (ImageButton) view.findViewById(R.id.moveKeyboardRightLeft);

        if (Common.startKeyboardContainerFromRight) {
            moveKeyboardRightLeft.setTag("right");
            moveKeyboardRightLeft.setImageResource(R.mipmap.ic_keyboard_arrow_left_white_48dp);
        } else {
            moveKeyboardRightLeft.setTag("left");
            moveKeyboardRightLeft.setImageResource(R.mipmap.ic_keyboard_arrow_right_white_48dp);
        }

        //Listeners
        makeKeyboardFullWidth.setAccessibilityDelegate(myAccessibilityEventHandler);
        makeKeyboardFullWidth.setOnTouchListener(this);

        moveKeyboardRightLeft.setAccessibilityDelegate(myAccessibilityEventHandler);
        moveKeyboardRightLeft.setOnTouchListener(this);

        //To get the width and height after before the view got rendered
        ViewTreeObserver viewTreeObserver = view.getViewTreeObserver();
        if (viewTreeObserver.isAlive()) {
            viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    makeKeyboardFullWidthRect.set(makeKeyboardFullWidth.getLeft(), makeKeyboardFullWidth.getTop(),
                            makeKeyboardFullWidth.getRight(), makeKeyboardFullWidth.getTop() + makeKeyboardFullWidth.getHeight());

                    moveKeyboardRightLeftRect.set(moveKeyboardRightLeft.getLeft(), moveKeyboardRightLeft.getTop(),
                            moveKeyboardRightLeft.getRight(), moveKeyboardRightLeft.getTop() + moveKeyboardRightLeft.getHeight());
                }
            });
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:MohammadAlBanna,项目名称:Swift-Braille-Soft-keyboard,代码行数:51,代码来源:RightLeftButtonsBar.java

示例5: onCreate

import android.widget.ImageButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // configure recycler view and adapter
    mChatRecycler = (RecyclerView) findViewById(R.id.chatRecyclerView);
    mChatRecycler.setHasFixedSize(true);
    mChatRecycler.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new ChatMessageAdapter();
    mChatRecycler.setAdapter(mAdapter);

    // configure text input
    mTextInput = (EditText) findViewById(R.id.user_input);
    mTextInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
            if (actionId != EditorInfo.IME_ACTION_GO) { return false; }

            cancelTimer();

            // send text input to web api and update view
            String text = mTextInput.getText().toString();
            mTextInput.setText("");
            mAdapter.addMessage(text, false);
            mChatRecycler.scrollToPosition(mAdapter.getItemCount() - 1);
            mConversation.sendText(text);

            return true;
        }
    });

    // configure speech input, hold button to talk
    mRecordButton = (ImageButton) findViewById(R.id.record_button);
    mRecordButton.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                mSpeechRecorder.start();
            }

            if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                mSpeechRecorder.stop();
            }
            return true;
        }
    });
}
 
开发者ID:pullstring,项目名称:pullstring-android,代码行数:49,代码来源:MainActivity.java

示例6: onFinishInflate

import android.widget.ImageButton; //导入方法依赖的package包/类
@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);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:71,代码来源:EmojiPalettesView.java


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