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.androguide.honamicontrol.fragments.HelpFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.cardsui, container, false);
    final ActionBarActivity fa = (ActionBarActivity) super.getActivity();
    fa.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    fa.getSupportActionBar().setHomeButtonEnabled(true);

    assert ll != null;
    CardUI mCardUI = (CardUI) (ll.findViewById(R.id.cardsui));
    mCardUI.addStack(new CardStack(""));

    mCardUI.addCard(new CardCategory(fa.getString(R.string.coming_soon),
            fa.getString(R.string.coming_soon_desc), fa.getString(R.string.help_center_color), "", false));

    mCardUI.addStack(new CardStack());
    mCardUI.refresh();//from  www  .  ja va  2 s  .c o  m
    return ll;
}

From source file:com.ridhofkr.hanacaraka.LetterCardActivity.java

private void addSoundListener(LinearLayout front) {
    final String text = ((String) ((TextView) front.findViewById(R.id.cardinfotitle)).getText()).toLowerCase()
            .replace('/', '_') + "_" + category;
    Button sound = (Button) front.findViewById(R.id.soundaksara);
    sound.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Log.e("audio", "play " + text);
            ctrl.playMusic(LetterCardActivity.this, text);
        }/*from   w ww.j a v  a2 s  .  c om*/
    });
}

From source file:com.google.android.gcm.demo.ui.TopicsFragment.java

@Override
public void refresh() {
    float density = getActivity().getResources().getDisplayMetrics().density;
    SimpleArrayMap<String, Sender> addressBook = mSenders.getSenders();
    LinearLayout sendersList = new LinearLayout(getActivity());
    sendersList.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < addressBook.size(); i++) {
        Sender sender = addressBook.valueAt(i);
        // Check if at least a topic is subscribed for this sender
        int subscribedTopics = 0;
        for (Boolean subscribed : sender.topics.values()) {
            if (subscribed) {
                subscribedTopics++;/*from   w  w w.  j  a v  a2 s.c o  m*/
            }
        }
        if (subscribedTopics > 0) {
            LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater()
                    .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
            ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon);
            TextView senderLabel = (TextView) senderRow.findViewById(R.id.widget_itbr_text);
            senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE);
            senderIcon.setImageResource(R.drawable.cloud_googblue);
            senderIcon.setPadding(0, 0, (int) (8 * density), 0);
            senderLabel.setText(getString(R.string.topics_sender_id, sender.senderId));
            sendersList.addView(senderRow);
            for (Map.Entry<String, Boolean> topic : sender.topics.entrySet()) {
                if (topic.getValue()) {
                    LinearLayout row = (LinearLayout) getActivity().getLayoutInflater()
                            .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
                    ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
                    TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
                    Button button = (Button) row.findViewById(R.id.widget_itbr_button);
                    icon.setImageResource(R.drawable.bigtop_updates_grey600);
                    label.setText(topic.getKey());
                    button.setText(R.string.topics_unsubscribe);
                    button.setTag(R.id.tag_action, ACTION_UNSUBSCRIBE);
                    button.setTag(R.id.tag_senderid, sender.senderId);
                    button.setTag(R.id.tag_topic, topic.getKey());
                    button.setOnClickListener(this);
                    row.setPadding((int) (16 * density), 0, 0, 0);
                    sendersList.addView(row);
                }
            }
        }
    }
    if (sendersList.getChildCount() == 0) {
        TextView noTokens = new TextView(getActivity());
        noTokens.setText(getString(R.string.topics_no_topic_subscribed));
        noTokens.setTypeface(null, Typeface.ITALIC);
        sendersList.addView(noTokens);
    }
    FrameLayout topicsView = (FrameLayout) getActivity().findViewById(R.id.topics_list_wrapper);
    topicsView.removeAllViews();
    topicsView.addView(sendersList);
}

From source file:fr.alecanu.samplerssreader.RssReaderActivity.java

private void refreshItemAnimationStarted() {
    final LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final LinearLayout iv = (LinearLayout) inflater.inflate(R.layout.action_view_refresh, null);
    final ImageView iconRefresh = (ImageView) iv.findViewById(R.id.action_view_refresh);
    final Animation rotation = AnimationUtils.loadAnimation(this, R.anim.refresh);

    if (rotation != null) {
        iconRefresh.startAnimation(rotation);
        mRefreshItem.setActionView(iv);/*from   w ww.  j a  va2  s .  c  o  m*/
    }
}

From source file:com.nextgis.ngm_clink_monitoring.dialogs.YesNoDialog.java

protected void setMessageView() {
    LinearLayout layout = (LinearLayout) View.inflate(getActivity(), R.layout.dialog_yes_no_message, null);
    mMessage = (TextView) layout.findViewById(R.id.dialog_message_yn);

    mDialogBodyScroll.setVisibility(View.VISIBLE);
    mDialogBodyLayoutScrolled.addView(layout);
}

From source file:com.google.android.gcm.demo.ui.InstanceIdFragment.java

@Override
public void refresh() {
    new AsyncTask<Void, Void, Void>() {
        @Override/*w  w  w  . j a  v  a 2  s .  c  om*/
        protected Void doInBackground(Void... params) {
            final String instanceId = mInstanceIdHelper.getInstanceId();
            final String creationTime = DateFormat.getDateTimeInstance()
                    .format(new Date(mInstanceIdHelper.getCreationTime()));
            final Activity activity = getActivity();
            if (activity != null) {
                Handler handler = new Handler(activity.getMainLooper());
                handler.post(new Runnable() {
                    public void run() {
                        setValue(activity.findViewById(R.id.iid_instance_id), instanceId);
                        setValue(activity.findViewById(R.id.iid_creation_time), creationTime);
                    }
                });
            }
            return null;
        }
    }.execute();
    float density = getActivity().getResources().getDisplayMetrics().density;
    SimpleArrayMap<String, Sender> addressBook = mSenders.getSenders();
    LinearLayout sendersList = new LinearLayout(getActivity());
    sendersList.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < addressBook.size(); i++) {
        Sender sender = addressBook.valueAt(i);
        if (sender.appTokens.size() > 0) {
            LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater()
                    .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
            ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon);
            TextView senderLabel = (TextView) senderRow.findViewById(R.id.widget_itbr_text);
            senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE);
            senderIcon.setImageResource(R.drawable.cloud_googblue);
            senderIcon.setPadding(0, 0, (int) (8 * density), 0);
            senderLabel.setText(getString(R.string.topics_sender_id, sender.senderId));
            sendersList.addView(senderRow);
            for (Token token : sender.appTokens.values()) {
                LinearLayout row = (LinearLayout) getActivity().getLayoutInflater()
                        .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
                ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
                TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
                Button button = (Button) row.findViewById(R.id.widget_itbr_button);
                icon.setImageResource(R.drawable.smartphone_grey600);
                label.setText(token.scope + " - " + AbstractFragment.truncateToMediumString(token.token));
                button.setText(R.string.iid_delete_token);
                button.setTag(R.id.tag_senderid, sender.senderId);
                button.setTag(R.id.tag_scope, token.scope);
                button.setOnClickListener(this);
                row.setPadding((int) (16 * density), 0, 0, 0);
                sendersList.addView(row);
            }
        }
    }
    if (sendersList.getChildCount() == 0) {
        TextView noTokens = new TextView(getActivity());
        noTokens.setText(getString(R.string.iid_no_tokens));
        noTokens.setTypeface(null, Typeface.ITALIC);
        sendersList.addView(noTokens);
    }
    FrameLayout tokensView = (FrameLayout) getActivity().findViewById(R.id.iid_tokens_wrapper);
    tokensView.removeAllViews();
    tokensView.addView(sendersList);
}

From source file:com.ubikod.capptain.android.sdk.reach.activity.CapptainPollActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    /* Init layout */
    super.onCreate(savedInstanceState);

    /* If no content, nothing to do, super class already called finish */
    if (mContent == null)
        return;/*from w  ww .  j a v a2s . c  o m*/

    /* Render questions */
    LinearLayout questionsLayout = getView("questions");
    JSONArray questions = mContent.getQuestions();
    LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    try {
        for (int i = 0; i < questions.length(); i++) {
            /* Get question */
            JSONObject question = questions.getJSONObject(i);

            /* Inflate question layout */
            LinearLayout questionLayout = (LinearLayout) layoutInflater
                    .inflate(getLayoutId("capptain_poll_question"), null);

            /* Set question's title */
            TextView questionTitle = (TextView) questionLayout.findViewById(getId("question_title"));
            questionTitle.setText(question.getString("title"));

            /* Set choices */
            RadioGroup choicesView = (RadioGroup) questionLayout.findViewById(getId("choices"));
            choicesView.setTag(question);
            JSONArray choices = question.getJSONArray("choices");
            int choiceViewId = 0;
            for (int j = 0; j < choices.length(); j++) {
                /* Get choice */
                JSONObject choice = choices.getJSONObject(j);

                /* Inflate choice layout */
                RadioButton choiceView = (RadioButton) layoutInflater
                        .inflate(getLayoutId("capptain_poll_choice"), null);

                /* Each choice is a radio button */
                choiceView.setId(choiceViewId++);
                choiceView.setTag(choice.getString("id"));
                choiceView.setText(choice.getString("title"));
                choiceView.setChecked(choice.getBoolean("default"));
                choicesView.addView(choiceView);
            }

            /* Add to parent layouts */
            questionsLayout.addView(questionLayout);

            /* Watch state */
            mRadioGroups.add(choicesView);
            choicesView.setOnCheckedChangeListener(mRadioGroupListener);
        }
    } catch (JSONException jsone) {
        /* Won't happen */
    }

    /* Disable action if a choice is not selected */
    updateActionState();
}

From source file:com.friedran.appengine.dashboard.gui.DashboardLoadFragment.java

private Spinner setSpinnerWithItems(LinearLayout layout, int optionsListResourceID, int spinnerResourceID) {
    Spinner spinner = (Spinner) layout.findViewById(spinnerResourceID);

    // Set options list
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mActivity, optionsListResourceID,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);/*from w  w  w.  j a va2 s . co m*/

    // Set listener
    spinner.setOnItemSelectedListener(this);

    return spinner;
}

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

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

    EditText showKeyboardEditText = null;
    EditText lastEditText = null;
    if (mScriptResolver.getConfigUi() != null) {
        TextView headerTextView = (TextView) addScrollingViewToFrame(R.layout.config_textview);
        headerTextView.setText(mScriptResolver.getDescription());
        for (ScriptResolverConfigUiField field : mScriptResolver.getConfigUi()) {
            Map<String, Object> config = mScriptResolver.getConfig();
            if (ScriptResolverConfigUiField.TYPE_TEXTVIEW.equals(field.type)) {
                TextView textView = (TextView) addScrollingViewToFrame(R.layout.config_textview);
                if (field.text.startsWith("<html>")) {
                    textView.setText(Html.fromHtml(field.text));
                    textView.setMovementMethod(LinkMovementMethod.getInstance());
                } else {
                    textView.setText(field.text);
                }
            } else if (ScriptResolverConfigUiField.TYPE_CHECKBOX.equals(field.type)) {
                LinearLayout checkboxLayout = (LinearLayout) addScrollingViewToFrame(R.layout.config_checkbox);
                TextView textView = (TextView) checkboxLayout.findViewById(R.id.config_textview);
                textView.setText(field.label);
                ConfigCheckbox checkBox = (ConfigCheckbox) checkboxLayout.findViewById(R.id.config_checkbox);
                checkBox.mConfigFieldId = field.id;
                mConfigFieldViews.add(checkBox);
                if (config.get(field.id) != null) {
                    checkBox.setChecked((Boolean) config.get(field.id));
                } else {
                    checkBox.setChecked(Boolean.valueOf(field.defaultValue));
                }
            } else if (ScriptResolverConfigUiField.TYPE_TEXTFIELD.equals(field.type)) {
                ConfigEdittext editText = (ConfigEdittext) addScrollingViewToFrame(R.layout.config_edittext);
                editText.mConfigFieldId = field.id;
                editText.setHint(field.label);
                mConfigFieldViews.add(editText);
                if (config.get(field.id) != null) {
                    editText.setText((String) config.get(field.id));
                } else {
                    editText.setText(field.defaultValue);
                }
                if (field.isPassword) {
                    editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
                    editText.setTransformationMethod(new PasswordTransformationMethod());
                }
                if (showKeyboardEditText == null) {
                    showKeyboardEditText = editText;
                }
                lastEditText = editText;
            } else if (ScriptResolverConfigUiField.TYPE_DROPDOWN.equals(field.type)) {
                LinearLayout numberpickerLayout = (LinearLayout) addScrollingViewToFrame(
                        R.layout.config_dropdown);
                TextView textView = (TextView) numberpickerLayout.findViewById(R.id.config_textview);
                textView.setText(field.label);
                ConfigDropDown dropDown = (ConfigDropDown) numberpickerLayout
                        .findViewById(R.id.config_dropdown);
                dropDown.mConfigFieldId = field.id;
                mConfigFieldViews.add(dropDown);
                List<CharSequence> list = new ArrayList<>();
                for (String item : field.items) {
                    list.add(item);
                }
                ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(TomahawkApp.getContext(),
                        R.layout.spinner_textview, list);
                adapter.setDropDownViewResource(R.layout.spinner_dropdown_textview);
                dropDown.setAdapter(adapter);
                if (config.get(field.id) != null) {
                    dropDown.setSelection(((Double) config.get(field.id)).intValue());
                } else {
                    dropDown.setSelection(Integer.valueOf(field.defaultValue));
                }
            }
        }
    }
    if (mScriptResolver.getScriptAccount().isManuallyInstalled()) {
        showRemoveButton(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                RemovePluginConfigDialog dialog = new RemovePluginConfigDialog();
                Bundle args = new Bundle();
                args.putString(TomahawkFragment.PREFERENCEID, mScriptResolver.getId());
                dialog.setArguments(args);
                dialog.show(getFragmentManager(), null);
                dismiss();
            }
        });
    }
    if (lastEditText != null) {
        lastEditText.setOnEditorActionListener(mOnKeyboardEnterListener);
    }
    if (showKeyboardEditText != null) {
        ViewUtils.showSoftKeyboard(showKeyboardEditText);
    }
    setDialogTitle(mScriptResolver.getName());

    showEnableButton(mEnableButtonListener);
    onResolverStateUpdated(mScriptResolver);

    hideNegativeButton();

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(getDialogView());
    return builder.create();
}

From source file:ru.gkpromtech.exhibition.NavigationDrawerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.fragment_navigation_drawer, container,
            false);//  w ww  . ja va2 s  .  c  om

    mDrawerListView = (ListView) layout.findViewById(R.id.listNav);
    mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectItem(position, true);
        }
    });
    String[] items = new String[Navigation.ITEMS.length];
    for (int i = 0, l = Navigation.ITEMS.length; i < l; ++i) {
        items[i] = getString(Navigation.ITEMS[i].getTitle());
    }
    mDrawerListView.setAdapter(new ArrayAdapter<>(getActionBar().getThemedContext(), R.layout.drawer_list_item,
            android.R.id.text1, items));
    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);

    return layout;
}