Example usage for android.view View.OnClickListener View.OnClickListener

List of usage examples for android.view View.OnClickListener View.OnClickListener

Introduction

In this page you can find the example usage for android.view View.OnClickListener View.OnClickListener.

Prototype

View.OnClickListener

Source Link

Usage

From source file:theintelligentminds.messenger.emoji.EmojiconsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.emojicons, container, false);
    final ViewPager emojisPager = (ViewPager) view.findViewById(R.id.emojis_pager);
    emojisPager.setOnPageChangeListener(this);
    EmojisPagerAdapter emojisAdapter = new EmojisPagerAdapter(getFragmentManager(), Arrays.asList(
            EmojiconGridFragment.newInstance(People.DATA), EmojiconGridFragment.newInstance(Nature.DATA),
            EmojiconGridFragment.newInstance(Objects.DATA), EmojiconGridFragment.newInstance(Places.DATA),
            EmojiconGridFragment.newInstance(Symbols.DATA)));
    emojisPager.setAdapter(emojisAdapter);

    mEmojiTabs = new View[5];
    mEmojiTabs[0] = view.findViewById(R.id.emojis_tab_0_people);
    mEmojiTabs[1] = view.findViewById(R.id.emojis_tab_1_nature);
    mEmojiTabs[2] = view.findViewById(R.id.emojis_tab_2_objects);
    mEmojiTabs[3] = view.findViewById(R.id.emojis_tab_3_cars);
    mEmojiTabs[4] = view.findViewById(R.id.emojis_tab_4_punctuation);
    for (int i = 0; i < mEmojiTabs.length; i++) {
        final int position = i;
        mEmojiTabs[i].setOnClickListener(new View.OnClickListener() {
            @Override/*from w  ww.ja  v a  2  s .c om*/
            public void onClick(View v) {
                emojisPager.setCurrentItem(position);
            }
        });
    }
    view.findViewById(R.id.emojis_backspace)
            .setOnTouchListener(new RepeatListener(1000, 50, new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnEmojiconBackspaceClickedListener != null) {
                        mOnEmojiconBackspaceClickedListener.onEmojiconBackspaceClicked(v);
                    }
                }
            }));
    onPageSelected(0);
    return view;
}

From source file:nz.ac.auckland.lablet.ExperimentRunViewManager.java

public ExperimentRunViewManager(final Activity activity, final int maxNumberOfRuns,
        final Experiment experiment) {
    this.experiment = experiment;

    // disable the selection layout for now
    View runSelectionLayout = activity.findViewById(R.id.runSelectionLayout);
    runSelectionLayout.setVisibility(View.INVISIBLE);
    addRunButton = (ImageButton) activity.findViewById(R.id.addRunButton);
    nextRunButton = (Button) activity.findViewById(R.id.nextButton);
    prevRunButton = (Button) activity.findViewById(R.id.prevButton);
    runView = (TextView) activity.findViewById(R.id.runGroupView);

    addRunButton.setOnClickListener(new View.OnClickListener() {
        @Override/* ww w . j av  a2s  .c  o  m*/
        public void onClick(View view) {
            ExperimentRun oldGroup = experiment.getCurrentExperimentRun();
            List<String> experimentNamesList = new ArrayList<>();
            for (IExperimentSensor experimentRun : oldGroup.getExperimentSensors())
                experimentNamesList.add(experimentRun.getClass().getSimpleName());
            ExperimentRun experimentRun = ExperimentRun.createExperimentRun(experimentNamesList);

            experiment.addExperimentRun(experimentRun);
            setCurrentExperimentRunGroup(experimentRun);

            if (maxNumberOfRuns > 0) {
                // check if we have the maximal number of runs
                List<ExperimentRun> runGroups = experiment.getExperimentRuns();
                if (runGroups.size() >= maxNumberOfRuns)
                    addRunButton.setEnabled(false);
            }
        }
    });

    nextRunButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            List<ExperimentRun> runGroups = experiment.getExperimentRuns();
            int index = runGroups.indexOf(experiment.getCurrentExperimentRun());
            index++;
            if (index >= runGroups.size())
                return;
            setCurrentExperimentRunGroup(runGroups.get(index));
        }
    });

    prevRunButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            List<ExperimentRun> runGroups = experiment.getExperimentRuns();
            int index = runGroups.indexOf(experiment.getCurrentExperimentRun());
            index--;
            if (index < 0)
                return;
            setCurrentExperimentRunGroup(runGroups.get(index));
        }
    });

    experiment.addListener(experimentListener);

    if (maxNumberOfRuns == 1)
        setVisibility(View.INVISIBLE);

    updateViews();
}

From source file:org.schabi.newpipe.about.LicenseFragment.java

@Nullable
@Override/*w w  w. j a  v a2  s. c  om*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_licenses, container, false);
    ViewGroup softwareComponentsView = rootView.findViewById(R.id.software_components);

    View licenseLink = rootView.findViewById(R.id.app_read_license);
    licenseLink.setOnClickListener(new OnReadFullLicenseClickListener());

    for (final SoftwareComponent component : softwareComponents) {
        View componentView = inflater.inflate(R.layout.item_software_component, container, false);
        TextView softwareName = componentView.findViewById(R.id.name);
        TextView copyright = componentView.findViewById(R.id.copyright);
        softwareName.setText(component.getName());
        copyright.setText(getContext().getString(R.string.copyright, component.getYears(),
                component.getCopyrightOwner(), component.getLicense().getAbbreviation()));

        componentView.setTag(component);
        componentView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Context context = v.getContext();
                if (context != null) {
                    showLicense(context, component.getLicense());
                }
            }
        });
        softwareComponentsView.addView(componentView);
        registerForContextMenu(componentView);
    }
    return rootView;
}

From source file:org.tanrabad.team.ChatFragment.java

private void initUiComponents(View rootView) {
    mListView = (ListView) rootView.findViewById(R.id.list);
    turnOffListViewDecoration(mListView);
    mListView.setAdapter(mAdapter);//  w  w  w  .jav  a  2 s.c  o m

    mBtnChannel = (ImageButton) rootView.findViewById(R.id.btn_channel);
    mBtnSend = (Button) rootView.findViewById(R.id.btn_send);
    mBtnUpload = (ImageButton) rootView.findViewById(R.id.btn_upload);
    mProgressBtnUpload = (ProgressBar) rootView.findViewById(R.id.progress_btn_upload);
    mEtxtMessage = (EditText) rootView.findViewById(R.id.etxt_message);

    mBtnSend.setEnabled(false);
    mBtnSend.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            send();
        }
    });

    mBtnChannel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mHandler != null) {
                mHandler.onChannelListClicked();
            }
        }
    });

    mBtnUpload.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent, "Select Picture"), REQUEST_PICK_IMAGE);
        }
    });

    mEtxtMessage.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                if (event.getAction() == KeyEvent.ACTION_DOWN) {
                    send();
                }
                return true; // Do not hide keyboard.
            }
            return false;
        }
    });
    mEtxtMessage.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    mEtxtMessage.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            mBtnSend.setEnabled(s.length() > 0);
        }
    });
    mListView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            SoftKeyboard.hide(getActivity());
            return false;
        }
    });
    mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == SCROLL_STATE_IDLE) {
                if (view.getFirstVisiblePosition() == 0 && view.getChildCount() > 0
                        && view.getChildAt(0).getTop() == 0) {
                    resultHandler = new MessageListQuery.MessageListQueryResult() {
                        @Override
                        public void onResult(List<MessageModel> messageModels) {
                            for (MessageModel model : messageModels) {
                                mAdapter.addMessageModel(model);
                            }

                            mAdapter.notifyDataSetChanged();
                            mListView.setSelection(messageModels.size());
                        }

                        @Override
                        public void onError(Exception e) {
                        }
                    };
                    SendBird.queryMessageList(SendBird.getChannelUrl()).prev(mAdapter.getMinMessageTimestamp(),
                            30, resultHandler);
                }
            }
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        }
    });
}

From source file:com.ted.androidscreenslide.app.LayoutChangesActivity.java

private void addItem() {
    // Instantiate a new "row" view.
    final ViewGroup newView = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.list_item_example,
            mContainerView, false);// w  ww.  j  av a2  s.  c o m

    // Set the text in the new row to a random country.
    ((TextView) newView.findViewById(android.R.id.text1))
            .setText(COUNTRIES[(int) (Math.random() * COUNTRIES.length)]);

    // Set a click listener for the "X" button in the row that will remove the row.
    newView.findViewById(R.id.delete_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Remove the row from its parent (the container view).
            // Because mContainerView has android:animateLayoutChanges set to true,
            // this removal is automatically animated.
            mContainerView.removeView(newView);

            // If there are no rows remaining, show the empty view.
            if (mContainerView.getChildCount() == 0) {
                findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
            }
        }
    });

    // Because mContainerView has android:animateLayoutChanges set to true,
    // adding this view is automatically animated.
    mContainerView.addView(newView, 0);
}

From source file:com.appnexus.opensdkapp.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Clog.v(Constants.BASE_LOG_TAG, "App created");

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

    initTabHost();//ww w  . j a  v a2  s.  c om
    initViewPager();

    tabHost.setOnTabChangedListener(this);

    // Default to Preview tab
    new Handler() {
        @Override
        public void handleMessage(Message msg) {
            onPageSelected(TABS.PREVIEW.ordinal());
        }
    }.sendEmptyMessage(0);

    btnMore = findViewById(R.id.btn_log);
    btnLog = findViewById(R.id.log_extension);

    btnMore.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (btnLog.getVisibility() == View.VISIBLE)
                btnLog.setVisibility(View.GONE);
            else
                btnLog.setVisibility(View.VISIBLE);
        }
    });

    btnLog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            view.setVisibility(View.GONE);
            showLogDialog();
        }
    });

    contentView = getWindow().findViewById(Window.ID_ANDROID_CONTENT);

    Clog.registerListener(logTabClogListener);
}

From source file:it.scoppelletti.mobilepower.widget.DateControl.java

/**
 * Inizializzazione.//from   w  ww  . j a v a2s .co  m
 * 
 * @param ctx Contesto.
 */
private void init(Context ctx) {
    View view;
    ImageButton cmd;
    LayoutInflater inflater;

    inflater = LayoutInflater.from(ctx);
    view = inflater.inflate(R.layout.datecontrol, this, false);
    addView(view);

    myValueControl = (EditText) findViewById(R.id.txt_value);
    myValueControl.setKeyListener(null);

    cmd = (ImageButton) findViewById(R.id.cmd_set);
    cmd.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            onSetClick();
        }
    });

    setValue(SimpleDate.NIL);

    cmd = (ImageButton) findViewById(R.id.cmd_reset);
    if (myIsResetEnabled) {
        cmd.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                setValue(SimpleDate.NIL);
            }
        });
    } else {
        cmd.setVisibility(View.GONE);
    }
}

From source file:ca.ippetad.geerweekapp.view.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /** View **/// w w w . ja  v a  2  s . co  m
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

    /** FRAGMENTS **/
    _frame = (FrameLayout) findViewById(R.id.container);

    _feed = new FeedFragment();
    _events = new EventsFragment();
    _kidnap = new KidnapFragment();
    _godiva = new GodivaFragment();
    _misc = new MiscFragment();

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.container, _feed).commit();
    }

    /** SLIDING MENU **/
    _slide = new SlidingMenu(this);
    _slide.setMode(SlidingMenu.LEFT);
    _slide.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    _slide.setBehindOffset(250);
    _slide.setFadeDegree(.9f);
    _slide.setBackgroundColor(Color.parseColor("#444444"));
    _slide.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    _slide.setMenu(R.layout.layout_menu);

    _slide.setOnOpenedListener(new SlidingMenu.OnOpenedListener() {
        @Override
        public void onOpened() {
            MENU_STATE = HIDDEN;
            invalidateOptionsMenu();
        }
    });
    _slide.setOnClosedListener(new SlidingMenu.OnClosedListener() {
        @Override
        public void onClosed() {
            MENU_STATE = VISIBLE;
            invalidateOptionsMenu();
        }
    });

    CustomTopBar bar = (CustomTopBar) findViewById(R.id.topbar);
    bar.setOnDrawerClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            _slide.toggle();
        }
    });

    ListView sliderList = (ListView) _slide.getRootView().findViewById(R.id.listview);
    CustomArrayAdapter slider_adapter = new CustomArrayAdapter(this, android.R.layout.simple_list_item_1,
            new String[] { "Home", "Events", "Kidnapping", "Godiva", "Misc" });
    sliderList.setAdapter(slider_adapter);
    sliderList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            switch (i) {
            case 0:
                getSupportFragmentManager().beginTransaction().replace(R.id.container, _feed)
                        .addToBackStack(null).commit();
                break;
            case 1:
                getSupportFragmentManager().beginTransaction().replace(R.id.container, _events)
                        .addToBackStack(null).commit();
                break;
            case 2:
                getSupportFragmentManager().beginTransaction().replace(R.id.container, _kidnap)
                        .addToBackStack(null).commit();
                break;
            case 3:
                getSupportFragmentManager().beginTransaction().replace(R.id.container, _godiva)
                        .addToBackStack(null).commit();
                break;
            case 4:
                getSupportFragmentManager().beginTransaction().replace(R.id.container, _misc)
                        .addToBackStack(null).commit();
                break;
            }
            _slide.toggle();
        }
    });

}

From source file:com.liu.Account.view.emojicon.EmojiconsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.emojicons, container, false);
    final ViewPager emojisPager = (ViewPager) view.findViewById(R.id.emojis_pager);
    emojisPager.setOnPageChangeListener(this);
    // we handle recents
    EmojiconRecents recents = this;
    mEmojisAdapter = new EmojisPagerAdapter(getFragmentManager(),
            Arrays.asList(EmojiconRecentsGridFragment.newInstance(mUseSystemDefault),
                    EmojiconGridFragment.newInstance(People.DATA, recents, mUseSystemDefault),
                    EmojiconGridFragment.newInstance(Nature.DATA, recents, mUseSystemDefault),
                    EmojiconGridFragment.newInstance(Objects.DATA, recents, mUseSystemDefault),
                    EmojiconGridFragment.newInstance(Places.DATA, recents, mUseSystemDefault),
                    EmojiconGridFragment.newInstance(Symbols.DATA, recents, mUseSystemDefault)));
    emojisPager.setAdapter(mEmojisAdapter);

    mEmojiTabs = new View[6];
    for (int i = 0; i < mEmojiTabs.length; i++) {
        final int position = i;
        mEmojiTabs[i].setOnClickListener(new View.OnClickListener() {
            @Override//w w  w  .  j a v  a2  s  .  c o m
            public void onClick(View v) {
                emojisPager.setCurrentItem(position);
            }
        });
    }
    view.findViewById(R.id.emojis_backspace)
            .setOnTouchListener(new RepeatListener(1000, 50, new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnEmojiconBackspaceClickedListener != null) {
                        mOnEmojiconBackspaceClickedListener.onEmojiconBackspaceClicked(v);
                    }
                }
            }));

    // get last selected page
    mRecentsManager = EmojiconRecentsManager.getInstance(view.getContext());
    int page = mRecentsManager.getRecentPage();
    // last page was recents, check if there are recents to use
    // if none was found, go to page 1
    if (page == 0 && mRecentsManager.size() == 0) {
        page = 1;
    }

    if (page == 0) {
        onPageSelected(page);
    } else {
        emojisPager.setCurrentItem(page, false);
    }
    return view;
}

From source file:com.torygaurnier.openpalette.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle saved_state) {
    view = inflater.inflate(R.layout.main_fragment, container, false);
    activity = (MainActivity) getActivity();
    clipboard = (ClipboardManager) activity.getSystemService(activity.CLIPBOARD_SERVICE);

    /**//from  w  w w  .  j  a va2 s.  c o  m
     * Setup Drawer for list of Palettes
     */
    drawer_layout = (DrawerLayout) view.findViewById(R.id.rootDrawerLayout);
    drawer_toggle = new ActionBarDrawerToggle(activity, drawer_layout, R.drawable.ic_navigation_drawer,
            R.string.drawer_open, R.string.drawer_close) {
        // Called when drawer closes
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            activity.refresh();
        }

        // Called when drawer opens
        public void onDrawerOpened(View drawer_view) {
            super.onDrawerOpened(drawer_view);
            activity.refresh();
        }
    };

    drawer_layout.setDrawerListener(drawer_toggle);

    // Set onclick listeners for 'new palette' buttons
    view.findViewById(R.id.createFirstPaletteButton).setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            new EditPaletteDialog(activity).show();
        }
    });
    view.findViewById(R.id.newPaletteButton).setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            new EditPaletteDialog(activity).show();
        }
    });

    // Get palette list view by it's ID, setup PaletteList
    palette_list_view = (ListView) view.findViewById(R.id.paletteListView);
    palette_list = PaletteList.getInstance();
    palette_list_view.setAdapter(palette_list.getAdapter());

    // Set on click listener for palette list view
    palette_list_view.setOnItemClickListener(new ListView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView adapter_view, View view, int position, long id) {
            // User clicked a list item, select it
            palette_list.setSelectedPosition(position);
        }
    });

    /**
     * Setup list view for current Palette
     */
    // Get palette view by its ID
    palette_view = (DragSortListView) view.findViewById(R.id.paletteView);
    palette_view.setOnItemClickListener(new ListView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView adapter_view, View view, int position, long id) {
            String hex = ((HexColor) adapter_view.getItemAtPosition(position)).getHex();
            ClipData clip = ClipData.newPlainText("hex", hex);
            clipboard.setPrimaryClip(clip);
            Msg.log(Msg.INFO, "palette_view->onItemClick()", hex + " copied to clipboard");
        }
    });

    // Register context menu for color actions
    registerForContextMenu(palette_view);

    activity.getActionBar().setDisplayHomeAsUpEnabled(true);
    activity.getActionBar().setHomeButtonEnabled(true);

    activity.refresh();
    return view;
}