Example usage for android.widget LinearLayout findViewById

List of usage examples for android.widget LinearLayout findViewById

Introduction

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

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:com.android.gallery3d.v5.filtershow.category.CategoryPanel.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LinearLayout main = (LinearLayout) inflater.inflate(R.layout.filtershow_category_panel_new, container,
            false);//from ww  w  .  j a  v  a 2  s .  com
    if (savedInstanceState != null) {
        int selectedPanel = savedInstanceState.getInt(PARAMETER_TAG);
        loadAdapter(selectedPanel);
    }

    View panelView = main.findViewById(R.id.listItems);
    if (panelView instanceof CategoryTrack) {
        CategoryTrack panel = (CategoryTrack) panelView;
        if (mAdapter != null) {
            mAdapter.setOrientation(CategoryView.HORIZONTAL);
            panel.setAdapter(mAdapter);
            mAdapter.setContainer(panel);
        }
    } else if (mAdapter != null) {
        ListView panel = (ListView) main.findViewById(R.id.listItems);
        panel.setAdapter(mAdapter);
        mAdapter.setContainer(panel);
    }

    mAddButton = (IconView) main.findViewById(R.id.addButton);
    if (mAddButton != null) {
        mAddButton.setOnClickListener(this);
        updateAddButtonVisibility();
    }
    return main;
}

From source file:com.thelastcrusade.soundstream.components.NetworkFragment.java

private void setButtonToDefaultState(LinearLayout button) {
    button.setEnabled(true);/*from   w  ww. j  av a2 s  .  c  om*/
    button.findViewById(R.id.searching).setVisibility(View.INVISIBLE);
    button.findViewById(R.id.image_background)
            .setBackgroundColor(getActivity().getResources().getColor(R.color.white));

}

From source file:com.rstar.mobile.thermocouple.ui.ThermocoupleKeypadFragment.java

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

    LinearLayout keypadPanel = (LinearLayout) v.findViewById(R.id.fragmentTcKeypad_id);

    for (int index = 0; index < size; index++) {
        // Prepare listener. May reuse if available.
        if (mOnKeyClickListeners[index] == null)
            mOnKeyClickListeners[index] = new OnKeyClickListener(this);

        mButtons[index] = (Button) keypadPanel.findViewById(button_ids[index]);
        mButtons[index].setText(ThermoCouple.type[index]);
        mButtons[index].setTag(ThermoCouple.type[index]);
        mButtons[index].setOnClickListener(mOnKeyClickListeners[index]);
    }//  w  ww .  j a  v a2 s.co  m

    return v;
}

From source file:org.ale.scanner.zotero.EditItemActivity.java

protected LinearLayout addTag() {
    LinearLayout crow = (LinearLayout) mInflater.inflate(R.layout.edit_tag_row, mTagList, false);

    ((TextView) crow.findViewById(R.id.label)).setText(ItemField.Localized.get(ItemField.Tag.tag));
    ((Button) crow.findViewById(R.id.add_tag)).setOnClickListener(addListener);
    ((Button) crow.findViewById(R.id.rm_tag)).setOnClickListener(rmListener);

    mTagList.addView(crow);//from   w w w.  j a  v  a  2s.  c o m
    return crow;
}

From source file:org.ale.scanner.zotero.EditItemActivity.java

protected LinearLayout addNote() {
    LinearLayout crow = (LinearLayout) mInflater.inflate(R.layout.edit_note_row, mNoteList, false);

    ((TextView) crow.findViewById(R.id.label)).setText(ItemField.Localized.get(ItemField.Note.note));
    ((Button) crow.findViewById(R.id.add_note)).setOnClickListener(addListener);
    ((Button) crow.findViewById(R.id.rm_note)).setOnClickListener(rmListener);

    mNoteList.addView(crow);//from w w  w  .  j  a v  a  2  s  .  co m
    return crow;
}

From source file:org.ale.scanner.zotero.EditItemActivity.java

protected LinearLayout addCreator() {
    LinearLayout crow = (LinearLayout) mInflater.inflate(R.layout.edit_creator_row, mCreatorList, false);
    ((Spinner) crow.findViewById(R.id.creator_type)).setAdapter(mSpinnerAdapter);
    ((Button) crow.findViewById(R.id.add_creator)).setOnClickListener(addListener);
    ((Button) crow.findViewById(R.id.rm_creator)).setOnClickListener(rmListener);
    mCreatorList.addView(crow);/*from   ww  w .j a va2s  .  c  o m*/
    return crow;
}

From source file:io.indy.drone.fragment.StrikeDetailFragment.java

private void updateUI(LinearLayout rootView) {

    attachAppropriateView(rootView);// ww  w . ja va2 s .com

    ((TextView) rootView.findViewById(R.id.strike_detail)).setText(mStrike.getBijSummaryShort());

    ((TextView) rootView.findViewById(R.id.location)).setText(mStrike.getLocation());

    String displayDate = DateFormatHelper.dateToDisplay(mStrike.getHappened());
    ((TextView) rootView.findViewById(R.id.happened)).setText(displayDate);

    ((TextView) rootView.findViewById(R.id.drone_summary)).setText(mStrike.getDroneSummary());

    // fire off a change size event
    View detailsView = mRootView.findViewById(R.id.details);
    onHeightChanged(detailsView.getHeight());

    configureButtons();

}

From source file:com.google.android.apps.forscience.whistlepunk.EditNoteDialog.java

@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
    mLabel = getArguments().getParcelable(KEY_SAVED_LABEL);
    String timeText = getArguments().getString(KEY_SAVED_TIME_TEXT, "");
    String timeTextContentDescription = getArguments().getString(KEY_SAVED_TIME_TEXT_DESCRIPTION);
    mTimestamp = getArguments().getLong(KEY_SAVED_TIMESTAMP);
    try {//  www  .  ja  va 2s  .  co m
        mSelectedValue = GoosciLabelValue.LabelValue.parseFrom(getArguments().getByteArray(KEY_SELECTED_VALUE));
    } catch (InvalidProtocolBufferNanoException ex) {
        Log.wtf(TAG, "Couldn't parse label value");
    }
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());

    LinearLayout rootView = (LinearLayout) LayoutInflater.from(getActivity())
            .inflate(R.layout.run_review_label_edit, null);
    alertDialog.setView(rootView);

    ImageView imageView = (ImageView) rootView.findViewById(R.id.picture_note_preview_image);
    final EditText editText = (EditText) rootView.findViewById(R.id.edit_note_text);
    TextView autoTextView = (TextView) rootView.findViewById(R.id.auto_note_text);

    // Use mSelectedValue to load content, because the user may have changed the value since
    // it was stored in the label. Note that picture labels can't be edited at this time,
    // but in the future this will apply to picture labels as well.
    if (mLabel instanceof PictureLabel) {
        imageView.setVisibility(View.VISIBLE);
        autoTextView.setVisibility(View.GONE);
        editText.setText(PictureLabel.getCaption(mSelectedValue));
        editText.setHint(R.string.picture_note_caption_hint);
        Glide.with(getActivity()).load(PictureLabel.getFilePath(mSelectedValue)).into(imageView);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PictureUtils.launchExternalViewer(getActivity(), (PictureLabel.getFilePath(mSelectedValue)));
            }
        });
    } else if (mLabel instanceof TextLabel) {
        imageView.setVisibility(View.GONE);
        autoTextView.setVisibility(View.GONE);
        editText.setText(TextLabel.getText(mSelectedValue));
    } else if (mLabel instanceof SensorTriggerLabel) {
        imageView.setVisibility(View.GONE);
        autoTextView.setVisibility(View.VISIBLE);
        editText.setText(SensorTriggerLabel.getCustomText(mSelectedValue));
        String autoText = SensorTriggerLabel.getAutogenText(mSelectedValue);
        TriggerHelper.populateAutoTextViews(autoTextView, autoText, R.drawable.ic_label_black_24dp,
                getResources());
    }

    alertDialog.setPositiveButton(R.string.action_save, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            mLabel.setTimestamp(mTimestamp);
            if (mLabel instanceof TextLabel) {
                ((TextLabel) mLabel).setText(editText.getText().toString());
            } else if (mLabel instanceof PictureLabel) {
                ((PictureLabel) mLabel).setCaption(editText.getText().toString());
            } else if (mLabel instanceof SensorTriggerLabel) {
                ((SensorTriggerLabel) mLabel).setCustomText(editText.getText().toString());
            }
            getDataController().editLabel(mLabel,
                    ((EditNoteDialogListener) getParentFragment()).onLabelEdit(mLabel));
        }
    });
    alertDialog.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    alertDialog.setCancelable(true);

    TextView timeTextView = (TextView) rootView.findViewById(R.id.edit_note_time);
    timeTextView.setText(timeText);
    timeTextView.setContentDescription(timeTextContentDescription);
    if (labelBelongsToRun() && mLabel.canEditTimestamp()) {
        timeTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                GoosciLabelValue.LabelValue value = new GoosciLabelValue.LabelValue();
                if (mLabel instanceof PictureLabel) {
                    // Captions can be edited, but the picture path cannot be edited at this
                    // time.
                    PictureLabel.populateStorageValue(value, ((PictureLabel) mLabel).getFilePath(),
                            editText.getText().toString());
                    ((EditNoteDialogListener) getParentFragment()).onEditNoteTimestampClicked(mLabel, value,
                            mTimestamp);
                } else if (mLabel instanceof TextLabel) {
                    TextLabel.populateStorageValue(value, editText.getText().toString());
                    ((EditNoteDialogListener) getParentFragment()).onEditNoteTimestampClicked(mLabel, value,
                            mTimestamp);
                }
            }
        });
    } else if (labelBelongsToRun()) {
        Drawable lockDrawable = getResources().getDrawable(R.drawable.ic_lock_black_18dp);
        DrawableCompat.setTint(lockDrawable, getResources().getColor(R.color.text_color_light_grey));
        // There is already a start drawable. Use it again.
        Drawable[] drawables = timeTextView.getCompoundDrawablesRelative();
        timeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(drawables[0], null, lockDrawable, null);
    }

    AlertDialog dialog = alertDialog.create();
    if (mLabel instanceof TextLabel || mLabel instanceof SensorTriggerLabel) {
        dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    }
    return dialog;
}

From source file:org.openmrs.mobile.activities.dialog.CustomFragmentDialog.java

public EditText addEditTextField(String defaultMessage) {
    LinearLayout field = (LinearLayout) mInflater.inflate(R.layout.openmrs_edit_text_field, null);
    EditText editText = (EditText) field.findViewById(R.id.openmrsEditText);
    if (null != defaultMessage) {
        editText.setText(defaultMessage);
    }//from ww w.j a  v a 2  s.c o  m
    mFieldsLayout.addView(field);
    return editText;
}

From source file:com.libtop.weituR.activity.main.DocUpload.FileListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LinearLayout mLinearLayout = (LinearLayout) inflater.inflate(R.layout.activity_doc_file_list, container,
            false);/* w  w w.j  av a 2s . co m*/
    listView = (ListView) mLinearLayout.findViewById(R.id.lv_doc);
    tvTitle = (TextView) mLinearLayout.findViewById(R.id.title);
    tvUpFolder = (TextView) mLinearLayout.findViewById(R.id.tv_up_folder);
    String[] splits = mPath.split("/");
    if (splits.length != 0) {
        String last = splits[splits.length - 1];
        tvUpFolder.setText(" > " + last);
    }
    tvUpFolder.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            upFolder();
        }
    });
    tvEmpty = (TextView) mLinearLayout.findViewById(R.id.tv_empty);
    tvCommit = (TextView) mLinearLayout.findViewById(R.id.commit);
    tvTitle.setText("");
    tvCommit.setText("??");
    tvCommit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            searchDoc();
        }
    });
    imgBack = (ImageView) mLinearLayout.findViewById(R.id.back_btn);
    listView.setAdapter(mAdapter);
    imgBack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            FileListAdapter adapter = (FileListAdapter) parent.getAdapter();
            if (adapter != null) {
                File file = (File) adapter.getItem(position);
                mPath = file.getAbsolutePath();
                mListener.onFileSelected(file);
            }
        }
    });

    return mLinearLayout;
}