Example usage for android.widget LinearLayout setOnClickListener

List of usage examples for android.widget LinearLayout setOnClickListener

Introduction

In this page you can find the example usage for android.widget LinearLayout setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.github.suzukaze.yarulistfortodoly.fragment.ToDoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.todo, container, false);
    ButterKnife.bind(this, view);

    final MainActivity mainActivity = (MainActivity) getActivity();
    todoViewModel = new TodoViewModel(accountManager, dataManager, historyManager);
    todoViewModel.setOnSyncFinishListener(this);
    Toolbar toolbar = mainActivity.getToolbar();
    toolbar.setTitle(getResources().getString(R.string.yarulist));
    mainActivity.showToolbar();/*from  ww w.ja va2  s.  c  om*/

    if (dataManager.getProjects().size() > 0) {
        currentProject = dataManager.getProjects().get(0);
    }

    syncLayout = mainActivity.getSyncLayout();
    final LinearLayout finalSyncLayout = syncLayout;
    finalSyncLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (underCommunication)
                return;
            finalSyncLayout.setVisibility(View.INVISIBLE);
            todoViewModel.sync();
        }
    });

    final ToDoFragment toDoFragment = this;

    LinearLayout addProject = mainActivity.getAddProjectLayout();
    addProject.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ProjectViewModel projectViewModel = new ProjectViewModel(dataManager, historyManager);
            projectViewModel.setProjectId(Project.PROJECT_ID_NONE);
            projectView.init(projectViewModel, mainActivity.getInputMethodManager(), toDoFragment, mainActivity,
                    currentProject, ProjectMode.ADD_PROJECT, accountManager, compositeSubscription);
            projectView.show();
        }
    });

    LinearLayout editProjectLayout = mainActivity.getEditProjectLayout();
    editProjectLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ProjectViewModel projectViewModel = new ProjectViewModel(dataManager, historyManager);
            projectViewModel.setProjectId(currentProject.getId());
            projectView.init(projectViewModel, mainActivity.getInputMethodManager(), toDoFragment, mainActivity,
                    currentProject, ProjectMode.UPDATE_PROJECT, accountManager, compositeSubscription);
            projectView.show();
        }
    });

    mainActivity.setEditItemView(editItemView);
    mainActivity.setProjectView(null);

    Resources r = getResources();
    tabs.setTextColor(r.getColor(R.color.white));
    tabs.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TABS_TEXT_SIZE);
    tabs.setTabIndicatorColor(r.getColor(R.color.white));

    dataManager = mainActivity.getDataManager();

    dataManager.clear();
    dataManager.load();
    if (sync) {
        todoViewModel.sync();
    } else {
        changeTabs();
    }

    return view;
}

From source file:com.yanzhenjie.recyclerview.swipe.SwipeMenuView.java

public void createMenu(SwipeMenu swipeMenu, SwipeSwitch swipeSwitch,
        SwipeMenuItemClickListener swipeMenuItemClickListener,
        @SwipeMenuRecyclerView.DirectionMode int direction) {
    removeAllViews();//from   w ww  .  j a  v a  2 s  .  c om

    this.mSwipeSwitch = swipeSwitch;
    this.mItemClickListener = swipeMenuItemClickListener;
    this.mDirection = direction;

    List<SwipeMenuItem> items = swipeMenu.getMenuItems();
    for (int i = 0; i < items.size(); i++) {
        SwipeMenuItem item = items.get(i);

        LayoutParams params = new LayoutParams(item.getWidth(), item.getHeight());
        params.weight = item.getWeight();
        LinearLayout parent = new LinearLayout(getContext());
        parent.setId(i);
        parent.setGravity(Gravity.CENTER);
        parent.setOrientation(VERTICAL);
        parent.setLayoutParams(params);
        ViewCompat.setBackground(parent, item.getBackground());
        parent.setOnClickListener(this);
        addView(parent);

        SwipeMenuBridge menuBridge = new SwipeMenuBridge(mDirection, i, mSwipeSwitch, parent);
        parent.setTag(menuBridge);

        if (item.getImage() != null) {
            ImageView iv = createIcon(item);
            menuBridge.mImageView = iv;
            parent.addView(iv);
        }

        if (!TextUtils.isEmpty(item.getText())) {
            TextView tv = createTitle(item);
            menuBridge.mTextView = tv;
            parent.addView(tv);
        }
    }
}

From source file:eu.power_switch.gui.fragment.main.RoomSceneTabFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.main_tabs, container, false);

    // Create the adapter that will return a fragment
    // for each of the two primary sections of the app.
    customTabAdapter = new CustomTabAdapter(getChildFragmentManager(), getActivity());

    // Set up the tabViewPager, attaching the adapter and setting up a listener
    // for when the user swipes between sections.
    tabViewPager = (ViewPager) rootView.findViewById(R.id.tabHost);
    tabViewPager.setAdapter(customTabAdapter);

    LinearLayout linearLayout_currentApartmentInfo = (LinearLayout) rootView
            .findViewById(R.id.linearLayout_currentApartmentInfo);
    linearLayout_currentApartmentInfo.setOnClickListener(new View.OnClickListener() {
        @Override//from w w w .j a  v  a  2s.co  m
        public void onClick(View v) {
            SelectApartmentDialog selectApartmentDialog = new SelectApartmentDialog();
            selectApartmentDialog.show(getFragmentManager(), null);
        }
    });

    textView_currentApartmentInfo = (TextView) rootView.findViewById(R.id.textView_currentApartmentInfo);
    updateCurrentApartmentInfo();

    tabViewPager.setOffscreenPageLimit(customTabAdapter.getCount());
    tabViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    tabViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            currentTab = position;
            if (!skipTutorial) {
                showTutorial(position);
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d(this, "received intent: " + intent.getAction());
            updateCurrentApartmentInfo();
        }
    };

    skipTutorial = true;

    tabLayout = (TabLayout) rootView.findViewById(R.id.tabLayout);
    tabLayout.setupWithViewPager(tabViewPager);

    Bundle args = getArguments();
    if (args != null && args.containsKey(TAB_INDEX_KEY)) {
        currentTab = args.getInt(TAB_INDEX_KEY);
        tabViewPager.setCurrentItem(currentTab);
    }

    skipTutorial = false;

    return rootView;
}

From source file:com.ultrafunk.network_info.config.ConfigActivity.java

private void initMobileSettingsScreenView() {
    LinearLayout mobileSettingsScreenLinearLayout = (LinearLayout) findViewById(
            R.id.mobileSettingsScreenLinearLayout);
    onDialogSelectionChanged(widgetConfig.getMobileDataSettingsScreen());

    mobileSettingsScreenLinearLayout.setOnClickListener(new View.OnClickListener() {
        @Override//from   ww  w  .  j  av a  2s .c  o m
        public void onClick(View view) {
            DialogFragment dialogFragment = new SettingsScreenDialogFragment();

            Bundle bundle = new Bundle();
            bundle.putInt(Constants.PREF_MOBILE_DATA_SETTINGS_SCREEN,
                    widgetConfig.getMobileDataSettingsScreen());
            dialogFragment.setArguments(bundle);
            dialogFragment.show(getSupportFragmentManager(), "SettingsScreenDialogFragment");
        }
    });
}

From source file:org.ciasaboark.tacere.activity.fragment.AdvancedSettingsFragment.java

private void drawLookaheadWidgets() {
    LinearLayout lookaheadBox = (LinearLayout) rootView.findViewById(R.id.advanced_settings_lookahead_box);
    lookaheadBox.setOnClickListener(new View.OnClickListener() {
        @Override/*from  ww  w .j a  va  2s.com*/
        public void onClick(View v) {
            final String[] intervals = Intervals.names();
            AlertDialog.Builder builder = new AlertDialog.Builder(
                    new ContextThemeWrapper(context, R.style.Dialog));
            builder.setTitle(R.string.advanced_settings_section_intervals_lookahead);

            builder.setSingleChoiceItems(intervals, -1, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    String intervalString = intervals[i];
                    int intervalValue = Intervals.getIntForStringValue(intervalString);
                    Intervals interval = Intervals.getTypeForInt(intervalValue);

                    prefs.setLookaheadDays(interval);
                    drawLookaheadWidgets();
                }
            });

            builder.setNeutralButton(R.string.close, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    //do nothing
                }
            });

            AlertDialog dialog = builder.show();
        }
    });

    // the lookahead interval button
    TextView lookaheadTV = (TextView) rootView.findViewById(R.id.lookaheadDaysDescription);
    String lookaheadText = getResources()
            .getString(R.string.advanced_settings_section_intervals_lookahead_duration);
    lookaheadTV.setText(String.format(lookaheadText, prefs.getLookaheadDays().injectString));
}

From source file:org.ciasaboark.tacere.activity.fragment.AdvancedSettingsFragment.java

private void drawEventBufferWidgets() {
    LinearLayout bufferBox = (LinearLayout) rootView.findViewById(R.id.advanced_settings_buffer_box);
    bufferBox.setOnClickListener(new View.OnClickListener() {
        @Override// w ww .j a va2s  . co m
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(
                    new ContextThemeWrapper(context, R.style.Dialog));
            builder.setTitle("Buffer Minutes");
            final NumberPicker number = new NumberPicker(context);
            String[] nums = new String[32];

            for (int i = 0; i < nums.length; i++) {
                nums[i] = Integer.toString(i);
            }

            number.setMinValue(1);
            number.setMaxValue(nums.length - 1);
            number.setWrapSelectorWheel(false);
            number.setDisplayedValues(nums);
            number.setValue(prefs.getBufferMinutes() + 1);

            builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    prefs.setBufferMinutes(number.getValue() - 1);
                    drawEventBufferWidgets();
                }
            });

            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // Do nothing
                }
            });

            builder.setView(number);

            AlertDialog dialog = builder.show();
        }
    });

    // the event buffer button
    TextView bufferTV = (TextView) rootView.findViewById(R.id.bufferMinutesDescription);
    String bufferText = getResources().getString(R.string.advanced_settings_section_intervals_buffer_duration);
    bufferTV.setText(String.format(bufferText, prefs.getBufferMinutes()));
}

From source file:de.enlightened.peris.ForumSettingsFragment.java

private void setupTextSettingsButton() {
    //Text settings button
    final LinearLayout forumSettingText = (LinearLayout) getActivity().findViewById(R.id.forum_setting_text);
    forumSettingText.setOnClickListener(new View.OnClickListener() {
        @Override/*  w  w w.  ja v  a 2  s .  co  m*/
        public void onClick(final View v) {
            final TextDialogFragment newFragment = TextDialogFragment.newInstance();
            newFragment.show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });
}

From source file:de.enlightened.peris.ForumSettingsFragment.java

private void setupAboutButton() {
    //About button
    final LinearLayout forumSettingAbout = (LinearLayout) getActivity().findViewById(R.id.forum_setting_about);
    forumSettingAbout.setOnClickListener(new View.OnClickListener() {
        @Override//w  w  w  . j a  v  a  2 s . com
        public void onClick(final View v) {
            final Intent aboutIntent = new Intent(getActivity(), About.class);
            startActivity(aboutIntent);
        }
    });
}

From source file:de.enlightened.peris.ForumSettingsFragment.java

private void setupClearCacheButton() {
    //Clear cache button
    final LinearLayout forumSettingCache = (LinearLayout) getActivity().findViewById(R.id.forum_setting_cache);
    forumSettingCache.setOnClickListener(new View.OnClickListener() {
        @Override//from   w w  w .  j  a va  2  s  .  c om
        public void onClick(final View v) {
            CacheNuker.nukeCache(getActivity());
            final Intent intro = new Intent(getActivity(), IntroScreen.class);

            getActivity().finish();
            if (!getString(R.string.server_location).contentEquals("0")) {
                getActivity().startActivity(intro);
            }
        }
    });
}

From source file:com.cyanogenmod.eleven.ui.activities.SlidingPanelActivity.java

@Override
protected void initBottomActionBar() {
    super.initBottomActionBar();
    // Bottom action bar
    final LinearLayout bottomActionBar = (LinearLayout) findViewById(R.id.bottom_action_bar);
    // Display the now playing screen or shuffle if this isn't anything
    // playing// w  w  w  . j a  v a  2  s  . co  m
    bottomActionBar.setOnClickListener(mOpenNowPlaying);
}