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:org.tomahawk.tomahawk_android.dialogs.ChoosePlaylistDialog.java

/**
 * Called when this {@link DialogFragment} is being created
 *///from w  w  w .j a  va2s  .  co m
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.choose_playlist_dialog, null);

    // Get all query keys from this fragment's arguments and through get the actual queries.
    final ArrayList<Query> queries = new ArrayList<Query>();
    if (getArguments() != null && getArguments().containsKey(TomahawkFragment.TOMAHAWK_QUERYARRAY_KEY)) {
        ArrayList<String> queryKeys = getArguments()
                .getStringArrayList(TomahawkFragment.TOMAHAWK_QUERYARRAY_KEY);
        if (queryKeys != null) {
            for (String queryKey : queryKeys) {
                queries.add(Query.getQueryByKey(queryKey));
            }
        }
    }

    final ArrayList<Playlist> playlists = CollectionManager.getInstance().getPlaylists();

    ListView listView = (ListView) view.findViewById(R.id.playlist_dialog_playlists_listview);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ArrayList<PlaylistEntry> entries = new ArrayList<PlaylistEntry>();
            Playlist playlist = playlists.get(position);
            for (Query query : queries) {
                entries.add(PlaylistEntry.get(playlist.getId(), query,
                        TomahawkMainActivity.getLifetimeUniqueStringId()));
            }
            CollectionManager.getInstance().addPlaylistEntries(playlist.getId(), entries);
            getDialog().dismiss();
        }
    });
    List<String> playlistNames = new ArrayList<String>();
    for (Playlist playlist : playlists) {
        playlistNames.add(playlist.getName());
    }
    listView.setAdapter(new TomahawkContextMenuAdapter(getActivity().getLayoutInflater(), playlistNames));
    LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.playlist_dialog_addplaylist_layout);
    linearLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Playlist playlist = Playlist.fromQueryList("", queries);
            CreatePlaylistDialog dialog = new CreatePlaylistDialog();
            Bundle args = new Bundle();
            args.putString(TomahawkFragment.TOMAHAWK_PLAYLIST_KEY, playlist.getId());
            dialog.setArguments(args);
            dialog.show(getFragmentManager(), null);
            getDialog().dismiss();
        }
    });
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(view);
    return builder.create();
}

From source file:nl.thehyve.transmartclient.fragments.AddNewServerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_addnewserver, container, false);
    getActivity().setTitle(R.string.addnewserver);

    final EditText serverUrlField = (EditText) rootView.findViewById(R.id.serverUrlField);
    final EditText serverLabelField = (EditText) rootView.findViewById(R.id.serverLabelField);
    final Button connect_button = (Button) rootView.findViewById(R.id.connect_button);

    if (serverUrl != null || serverLabel != null) {
        serverUrlField.setText(serverUrl);
        serverLabelField.setText(serverLabel);
    }/*from   w w w .  j  av a  2 s . c o m*/

    if (waitingForToken) {
        // TODO show loading sign
        serverUrlField.setEnabled(false);
        serverLabelField.setEnabled(false);
        connect_button.setEnabled(false);
    }

    LinearLayout exampleContainer = (LinearLayout) rootView.findViewById(R.id.exampleContainer);
    exampleContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            serverUrlField.setText(getString(R.string.urlExample));
            serverLabelField.setText(getString(R.string.labelExample));
        }
    });

    serverLabelField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_GO) {
                connect_button.performClick();
                return true;
            }
            return false;
        }
    });

    return rootView;
}

From source file:ca.ualberta.cmput301w14t08.geochan.fragments.ExpandImageFragment.java

/**
 * Initializes the UI of the fragment.//from   w w  w  . ja  v a 2  s .com
 */
@Override
public void onStart() {
    super.onStart();
    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setMessage("Downloading Image");
    ImageView imageView = (ImageView) getView().findViewById(R.id.expanded_image);
    final Bitmap image = CacheManager.getInstance().deserializeImage(id);
    if (image == null) {
        // Start the image getter thread.
        ThreadManager.startGetImage(id, imageView, dialog);
    } else {
        imageView.setImageBitmap(image);
        ThreadManager.startGetImage(id, imageView, null);
    }
    LinearLayout rlayout = (LinearLayout) getView().findViewById(R.id.expanded_image_relative);
    rlayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            getFragmentManager().popBackStack();
        }
    });
    Button saveButton = (Button) getView().findViewById(R.id.save_image_button);
    saveButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ContentValues values = new ContentValues();
            values.put(Images.Media.TITLE, id);
            values.put(Images.Media.DESCRIPTION, id);
            values.put(Images.Media.MIME_TYPE, "image/jpeg");
            values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());

            Uri uri = null;
            ContentResolver contentResolver = getActivity().getContentResolver();
            try {
                uri = contentResolver.insert(Images.Media.EXTERNAL_CONTENT_URI, values);
                OutputStream imageOut = contentResolver.openOutputStream(uri);
                try {
                    image.compress(Bitmap.CompressFormat.JPEG, 90, imageOut);
                } finally {
                    imageOut.close();
                }
                Toast.makeText(getActivity(), "Saved to gallery.", Toast.LENGTH_SHORT).show();
            } catch (Exception e) {
                Toaster.toastShort("Failed to save to gallery.");
                if (uri != null) {
                    contentResolver.delete(uri, null, null);
                    uri = null;
                }
            }
        }
    });
}

From source file:bf.io.openshop.ux.fragments.SettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Timber.d("%s - onCreateView", this.getClass().getSimpleName());
    View view = inflater.inflate(R.layout.fragment_settings, container, false);

    MainActivity.setActionBarTitle(getString(R.string.Settings));

    progressDialog = Utils.generateProgressDialog(getActivity(), false);

    spinShopSelection = (Spinner) view.findViewById(R.id.settings_shop_selection_spinner);

    LinearLayout licensesLayout = (LinearLayout) view.findViewById(R.id.settings_licenses_layout);
    licensesLayout.setOnClickListener(new View.OnClickListener() {
        @Override// ww w. j  a v  a2s .  c o  m
        public void onClick(View v) {
            LicensesDialogFragment df = new LicensesDialogFragment();
            df.show(getFragmentManager(), LicensesDialogFragment.class.getSimpleName());
        }
    });

    requestShops();
    return view;
}

From source file:org.runbuddy.tomahawk.dialogs.ResolverRedirectConfigDialog.java

/**
 * Called when this {@link android.support.v4.app.DialogFragment} is being created
 *//*from   w ww  .j  ava2  s.  c om*/
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (getArguments() != null && getArguments().containsKey(TomahawkFragment.PREFERENCEID)) {
        String id = getArguments().getString(TomahawkFragment.PREFERENCEID);
        mScriptResolver = PipeLine.get().getResolver(id);
    }

    TextView headerTextView = (TextView) addScrollingViewToFrame(R.layout.config_textview);
    headerTextView.setText(mScriptResolver.getDescription());

    mWarningTextView = (TextView) addScrollingViewToFrame(R.layout.config_textview);

    View buttonLayout = addScrollingViewToFrame(R.layout.config_enable_button);
    LinearLayout button = (LinearLayout) buttonLayout.findViewById(R.id.config_enable_button);
    button.setOnClickListener(new RedirectButtonListener());
    ImageView buttonImage = (ImageView) buttonLayout.findViewById(R.id.config_enable_button_image);
    mScriptResolver.loadIconWhite(buttonImage, 0);
    mRedirectButtonTextView = (TextView) button.findViewById(R.id.config_enable_button_text);

    updateTextViews();

    setDialogTitle(mScriptResolver.getName());
    hideNegativeButton();
    onResolverStateUpdated(mScriptResolver);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(getDialogView());
    return builder.create();
}

From source file:org.videolan.vlc.widget.AudioMiniPlayer.java

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

    // Initialize the children
    mCover = (ImageView) v.findViewById(R.id.cover);
    mTitle = (TextView) v.findViewById(R.id.title);
    mArtist = (TextView) v.findViewById(R.id.artist);
    mPlayPause = (ImageButton) v.findViewById(R.id.play_pause);
    mForward = (ImageButton) v.findViewById(R.id.forward);
    mBackward = (ImageButton) v.findViewById(R.id.backward);
    mPlayPause.setOnClickListener(onMediaControlClickListener);
    mForward.setOnClickListener(onMediaControlClickListener);
    mBackward.setOnClickListener(onMediaControlClickListener);
    mProgressBar = (ProgressBar) v.findViewById(R.id.timeline);

    LinearLayout root = (LinearLayout) v.findViewById(R.id.root_node);

    root.setOnClickListener(new OnClickListener() {
        @Override/*from www .jav a 2  s  .  co m*/
        public void onClick(View v) {
            AudioPlayerActivity.start(getActivity());
        }
    });

    registerForContextMenu(v);
    return v;
}

From source file:org.videolan.myvlc.core.widget.AudioMiniPlayerFragment.java

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

    // Initialize the children
    mCover = (ImageView) v.findViewById(R.id.cover);
    mTitle = (TextView) v.findViewById(R.id.title);
    mArtist = (TextView) v.findViewById(R.id.artist);
    mPlayPause = (ImageButton) v.findViewById(R.id.play_pause);
    mForward = (ImageButton) v.findViewById(R.id.forward);
    mBackward = (ImageButton) v.findViewById(R.id.backward);
    mPlayPause.setOnClickListener(onMediaControlClickListener);
    mForward.setOnClickListener(onMediaControlClickListener);
    mBackward.setOnClickListener(onMediaControlClickListener);
    mProgressBar = (ProgressBar) v.findViewById(R.id.timeline);

    LinearLayout root = (LinearLayout) v.findViewById(R.id.root_node);

    root.setOnClickListener(new OnClickListener() {
        @Override/*  www.j a v  a2  s .  c  om*/
        public void onClick(View v) {
            //AudioPlayerActivity.start(getActivity());
        }
    });

    registerForContextMenu(v);
    return v;
}

From source file:com.coinprism.wallet.fragment.BalanceTab.java

/**
 * Constructs the UI when the activity is first rendered.
 *
 * @param rootView the rootView of the fragment
 *///  w  w  w . j  a  va  2  s.  co  m
public void setupUI(final View rootView) {
    final WalletState state = WalletState.getState();

    final TextView addressText = (TextView) rootView.findViewById(R.id.address);
    final ImageView qrCode = (ImageView) rootView.findViewById(R.id.qrAddress);

    final ToggleButton addressTypeSelector = (ToggleButton) rootView.findViewById(R.id.addressTypeSelector);

    final View.OnClickListener enlarge = new View.OnClickListener() {
        // Enlarge the QR code
        @Override
        public void onClick(View view) {
            final QRCodeDialog dialog = new QRCodeDialog();
            if (addressTypeSelector.isChecked()) {
                dialog.configure(WalletState.getState().getConfiguration().getReceiveAssetAddress(),
                        getString(R.string.tab_wallet_dialog_qr_title_assets));
            } else {
                dialog.configure(WalletState.getState().getConfiguration().getAddress(),
                        getString(R.string.tab_wallet_dialog_qr_title_bitcoin));
            }

            dialog.show(BalanceTab.this.getActivity().getSupportFragmentManager(), "");
        }
    };

    LinearLayout addressPanel = (LinearLayout) rootView.findViewById(R.id.addressArea);
    addressPanel.setOnClickListener(enlarge);
    qrCode.setOnClickListener(enlarge);

    addressTypeSelector.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (addressTypeSelector.isChecked()) {
                addressText.setText(state.getConfiguration().getReceiveAssetAddress());
                QRCodeEncoder.createQRCode(state.getConfiguration().getReceiveAssetAddress(), qrCode, 148, 148,
                        8, 0xFFFFFFFF);
            } else {
                addressText.setText(state.getConfiguration().getAddress());
                QRCodeEncoder.createQRCode(state.getConfiguration().getAddress(), qrCode, 148, 148, 8,
                        0xFFFFFFFF);
            }
        }
    });

    addressTypeSelector.setChecked(true);
}

From source file:com.boding.app.AddLowpriceSubsActivity.java

private void initView() {
    LinearLayout returnLogoLinearLayout = (LinearLayout) findViewById(R.id.return_logo_linearLayout);
    returnLogoLinearLayout.setOnClickListener(new OnClickListener() {
        @Override//from www  . j a va  2 s.com
        public void onClick(View arg0) {
            Util.returnToPreviousPage(AddLowpriceSubsActivity.this, IntentRequestCode.ADD_LOWPRICESUBS);
        }
    });

    completeLinearLayout = (LinearLayout) findViewById(R.id.addlowpricesubs_complete_linearLayout);
    completeLinearLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (GlobalVariables.currentSubscribe.getSubscribeWay() == 2
                    && GlobalVariables.currentSubscribe.getPrice() == 0) {
                warningDialog.setContent("");
                warningDialog.show();
                return;
            }
            if (GlobalVariables.currentSubscribe.getMobile().equals("")
                    || !RegularExpressionsUtil.checkMobile(GlobalVariables.currentSubscribe.getMobile())) {
                warningDialog.setContent("");
                warningDialog.show();
                return;
            }
            if (!Util.isNetworkAvailable(AddLowpriceSubsActivity.this)) {
                networkUnavaiableDialog.show();
                return;
            }

            progressBarDialog.show();
            (new LowPriceSubscribeTask(AddLowpriceSubsActivity.this, HTTPAction.ADD_LOWPRICESUB))
                    .execute(GlobalVariables.currentSubscribe);
        }
    });
}

From source file:com.melvin.android.base.common.ui.TabPageIndicator.java

private void addTab(String text, int index) {
    // Workaround for not being able to pass a defStyle on pre-3.0
    RFileUtil fileUtil = RFileUtil.getInstance(this.mContext);
    int layoutid = fileUtil.getLayoutValue("tab_item_layout");
    LinearLayout linear = (LinearLayout) mInflater.inflate(layoutid, null);
    linear.setFocusable(true);// w  ww. jav a2 s.c o  m
    linear.setOnClickListener(mTabClickListener);
    TextView vv = (TextView) linear.findViewById(android.R.id.text1);
    vv.setText(text);
    linear.setTag(index);
    mTabLayout.addView(linear, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));
}