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.nsboc.ComposeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (mItem != null) {
        switch (mItem.id + "") {
        case "1":
            mRootView = inflater.inflate(R.layout.form_unlicensed, container, false);
            break;
        case "2":
            mRootView = inflater.inflate(R.layout.form_salon, container, false);
            break;
        }/*from  ww  w  . ja  v a  2s . c  om*/
    }

    showCurrentDateInEditText();

    ToggleButton complianceToggle = (ToggleButton) mRootView.findViewById(R.id.compliance_toggle);
    if (complianceToggle != null) {
        final LinearLayout complianceContainer = (LinearLayout) mRootView
                .findViewById(R.id.compliance_container);

        complianceToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (!isChecked) {
                    complianceContainer.setVisibility(View.VISIBLE);

                    final LinearLayout complianceLayout = (LinearLayout) View.inflate(getActivity(),
                            R.layout.compliance_layout, null);

                    Spinner violationTypeSpinner = (Spinner) complianceLayout
                            .findViewById(R.id.violation_type_spinner);
                    violationTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                        @Override
                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                            switch (position) {
                            case 0:
                                complianceLayout.findViewById(R.id.type_citation_container)
                                        .setVisibility(View.VISIBLE);
                                break;
                            case 1:
                                complianceLayout.findViewById(R.id.type_citation_container)
                                        .setVisibility(View.GONE);
                                break;
                            }
                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> parent) {
                        }
                    });

                    ToggleButton anotherToggle = (ToggleButton) complianceLayout
                            .findViewById(R.id.compliance_toggle);
                    anotherToggle.setOnCheckedChangeListener(getNextToggleListener(complianceLayout));

                    complianceContainer.addView(complianceLayout);
                } else {
                    complianceContainer.setVisibility(View.GONE);
                }
            }
        });
    }

    ToggleButton emailToggle = (ToggleButton) mRootView.findViewById(R.id.emailTo_toggle);
    if (emailToggle != null) {
        final LinearLayout emailLayout = (LinearLayout) mRootView.findViewById(R.id.emailTo_layout);

        emailToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    emailLayout.setVisibility(View.VISIBLE);
                } else {
                    emailLayout.setVisibility(View.GONE);
                }
            }
        });
    }

    final TextView noticeTextView = (TextView) mRootView.findViewById(R.id.notice_textview);
    if (noticeTextView != null) {
        noticeTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (noticeTextView.getCurrentTextColor() == Color.BLACK) {
                    noticeTextView.setText(R.string.civil_citation_header);
                    noticeTextView.setTextColor(Color.parseColor("#17405e"));
                    noticeTextView.setText(Html.fromHtml("<u>" + noticeTextView.getText() + "</u>"));
                    mRootView.findViewById(R.id.civil_citation).requestFocus();
                } else {
                    noticeTextView.setText(R.string.civil_citation_notice);
                    noticeTextView.setMaxLines(Integer.MAX_VALUE);
                    noticeTextView.setTextColor(Color.BLACK);
                    noticeTextView.setText(
                            noticeTextView.getText().toString().replace("<u>", "").replace("</u>", ""));
                }
            }
        });
    }

    Spinner stateSpinner = (Spinner) mRootView.findViewById(R.id.state);
    if (stateSpinner != null) {
        stateSpinner.setSelection(27);
    }

    return mRootView;
}

From source file:com.money.manager.ex.reports.CategoriesReportFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    setListAdapter(null);/*  w  w  w. j  a  va 2  s. c  om*/
    setSearchMenuVisible(true);

    //create header view
    LinearLayout mListViewHeader = (LinearLayout) addListViewHeaderFooter(
            R.layout.item_generic_report_2_columns);
    TextView txtColumn1 = (TextView) mListViewHeader.findViewById(R.id.textViewColumn1);
    TextView txtColumn2 = (TextView) mListViewHeader.findViewById(R.id.textViewColumn2);
    //set header
    txtColumn1.setText(R.string.category);
    txtColumn1.setTypeface(null, Typeface.BOLD);
    txtColumn2.setText(R.string.amount);
    txtColumn2.setTypeface(null, Typeface.BOLD);
    //add to list view
    getListView().addHeaderView(mListViewHeader);

    //create footer view
    mListViewFooter = (LinearLayout) addListViewHeaderFooter(R.layout.item_generic_report_2_columns);
    txtColumn1 = (TextView) mListViewFooter.findViewById(R.id.textViewColumn1);
    txtColumn2 = (TextView) mListViewFooter.findViewById(R.id.textViewColumn2);
    //set footer
    txtColumn1.setText(R.string.total);
    txtColumn1.setTypeface(null, Typeface.BOLD_ITALIC);
    txtColumn2.setText(R.string.total);
    txtColumn2.setTypeface(null, Typeface.BOLD_ITALIC);

    //add to list view --> move to load finished
    //getListView().addFooterView(mListViewFooter);

    //set adapter
    CategoriesReportAdapter adapter = new CategoriesReportAdapter(getActivity(), null);
    setListAdapter(adapter);
    //call super method
    super.onActivityCreated(savedInstanceState);
}

From source file:org.mifos.androidclient.templates.OperationFormActivity.java

public EditText addDateFormField(String fieldLabel) {
    LinearLayout field = (LinearLayout) getLayoutInflater().inflate(R.layout.date_form_field, null);
    TextView label = (TextView) field.findViewById(R.id.dateFormField_label);
    label.setText(fieldLabel);//from   w  w  w  . j a  v a2 s.  co m
    EditText input = (EditText) field.findViewById(R.id.dateFormField_input);
    input.setInputType(InputType.TYPE_NULL);
    input.setOnFocusChangeListener(this);
    mFormFields.addView(field, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    return input;
}

From source file:org.ohmage.prompt.remoteactivity.RemoteActivityPrompt.java

/**
 * Creates the View from an XML file and sets up the local variables for
 * the Views contained within. Then, if automatic launch is turned on it
 * will attempt to automatically launch the remote Activity.
 *///  w  w w  . jav a 2s  . com
@Override
public View getView(Context context) {
    try {
        callingActivity = (Activity) context;
    } catch (ClassCastException e) {
        callingActivity = null;
        Log.e(TAG, "getView() recieved a Context that wasn't an Activity.");
        // Should we error out here?
    }

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.prompt_remote_activity, null);

    feedbackText = (TextView) layout.findViewById(R.id.prompt_remote_activity_feedback);
    launchButton = (Button) layout.findViewById(R.id.prompt_remote_activity_replay_button);
    launchButton.setOnClickListener(this);
    launchButton.setText((!launched && !autolaunch) ? "Launch" : "Relaunch");

    if (retries > 0) {
        launchButton.setVisibility(View.VISIBLE);
    } else {
        if (!launched && !autolaunch) {
            launchButton.setVisibility(View.VISIBLE);
        } else {
            launchButton.setVisibility(View.GONE);
        }
    }

    if (autolaunch && !launched) {
        launchActivity();
    }

    return layout;
}

From source file:org.mifos.androidclient.templates.OperationFormActivity.java

public CheckBox addCheckBoxFormField(String fieldLabel) {
    LinearLayout field = (LinearLayout) getLayoutInflater().inflate(R.layout.check_box_form_field, null);
    CheckBox input = (CheckBox) field.findViewById(R.id.checkBox_label);
    input.setText(fieldLabel);/*from   w  ww  .j  a v  a  2 s.  c o m*/
    input.setInputType(InputType.TYPE_NULL);
    mFormFields.addView(field, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    return input;
}

From source file:org.mifos.androidclient.templates.OperationFormActivity.java

private EditText addFormField(String fieldLabel, int inputType) {
    LinearLayout field = (LinearLayout) getLayoutInflater().inflate(R.layout.edit_text_form_field, null);
    TextView label = (TextView) field.findViewById(R.id.editTextFormField_label);
    label.setText(fieldLabel);/* w w  w  .  j  a  va 2  s .co m*/
    EditText input = (EditText) field.findViewById(R.id.editTextFormField_input);
    input.setInputType(inputType);
    mFormFields.addView(field, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    return input;
}

From source file:org.mifos.androidclient.templates.OperationFormActivity.java

public Spinner addComboBoxFormField(String fieldLabel, List<String> elements) {
    LinearLayout field = (LinearLayout) getLayoutInflater().inflate(R.layout.combo_box_form_field, null);
    TextView label = (TextView) field.findViewById(R.id.comboBoxFormField_label);
    label.setText(fieldLabel);//from w  w  w  .j a  va  2s  .c o  m
    Spinner input = (Spinner) field.findViewById(R.id.comboBoxFormField_input);
    input.setPrompt(fieldLabel);
    input.setAdapter(new ArrayAdapter(this, R.layout.combo_box_item, elements));
    mFormFields.addView(field, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    return input;
}

From source file:dcheungaa.procal.MainActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override/*from w  ww  .  ja  va 2 s.c  o  m*/
@NonNull
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.

    switch (item.getItemId()) {

    case R.id.nav_history:
        Intent intent = new Intent(MainActivity.context, HistoryActivity.class);
        startActivity(intent);
        return true;

    case R.id.nav_about:

        String credits = "<p>This piece of software used the work <a href=\"https://arxiv.org/abs/0908.3030v1\">\"A Java Math.BigDecimal Implementation of Core Mathematical Functions\" of Richard J. Mathar</a>, which was made available under the LGPL3.0 license as a library. As part of the obligations to the license, if the user wish to replace this library with their own, they may contact: <a href=\"mailto:dcheungaa@connect.ust.hk\">dcheungaa@connect.ust.hk</a></p>\n"
                + "\n" + "<p>Other code libraries used:</p>\n"
                + "<p><a href=\"https://github.com/atorstling/bychan\">Bychan</a><br>\n"
                + "<a href=\"https://github.com/evant/gradle-retrolambda\">Gradle-Retrolambda</a><br>\n"
                + "<a href=\"https://github.com/streamsupport/streamsupport\">SteamSupport</a></p>\n";

        final AlertDialog.Builder builder_add = new AlertDialog.Builder(MainActivity.this);
        builder_add.setTitle("About");
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        LinearLayout aboutLayout = (LinearLayout) inflater.inflate(R.layout.about_alert, null);
        builder_add.setView(aboutLayout);
        TextView aboutTextView = (TextView) aboutLayout.findViewById(R.id.about_content);
        aboutTextView.setText(Html.fromHtml(credits));
        aboutTextView.setMovementMethod(LinkMovementMethod.getInstance());

        builder_add.setPositiveButton("Close", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                dialog.dismiss();
            }
        });
        AlertDialog alert_add = builder_add.create();
        alert_add.show();
        return true;

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:de.dmxcontrol.fragment.ActionSelectorFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView");

    LinearLayout actionButtons = (LinearLayout) inflater.inflate(R.layout.action_selector_fragment, container,
            false);/*  w ww. j  a  v  a  2s.  c  o  m*/

    ViewGroup vg = (ViewGroup) actionButtons.findViewById(R.id.action_selector_scroll);
    scrollView = vg;

    bDeviceAction = (Button) actionButtons.findViewById(R.id.button_device_action);
    bDeviceAction.setOnClickListener(this);
    bDeviceAction.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            try {
                AlertDialog.Builder alert = new AlertDialog.Builder(v.getContext());
                alert.setTitle("Parameter");
                final DeviceManagerDialog view = new DeviceManagerDialog(alert.getContext());
                alert.setView(view);
                alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        try {
                            ServiceFrontend.get().sendMessage(view.GetDeviceMetadata().getBytes());
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                });
                AlertDialog alertDialog = alert.create();
                alertDialog.show();
                return true;
            } catch (Exception e) {
                return false;
            }
        }
    });

    bColorAction = (Button) actionButtons.findViewById(R.id.button_color_action);
    bColorAction.setOnClickListener(this);

    bIntensityAction = (Button) actionButtons.findViewById(R.id.button_intensity_action);
    bIntensityAction.setOnClickListener(this);

    bPanTiltAction = (Button) actionButtons.findViewById(R.id.button_pantilt_action);
    bPanTiltAction.setOnClickListener(this);

    bGoboAction = (Button) actionButtons.findViewById(R.id.button_gobo_action);
    bGoboAction.setOnClickListener(this);

    bOpticAction = (Button) actionButtons.findViewById(R.id.button_optic_action);
    bOpticAction.setOnClickListener(this);

    bPrismAction = (Button) actionButtons.findViewById(R.id.button_prism_action);
    bPrismAction.setOnClickListener(this);
    //bOpticAction.setVisibility(View.INVISIBLE);
    //actionButtons.removeView(bOpticAction);

    bRawAction = (Button) actionButtons.findViewById(R.id.button_raw_action);
    bRawAction.setOnClickListener(this);
    //bRawAction.setVisibility(View.INVISIBLE);
    //actionButtons.removeView(bRawAction);

    bEffectAction = (Button) actionButtons.findViewById(R.id.button_effect_action);
    bEffectAction.setOnClickListener(this);
    //bEffectAction.setVisibility(View.INVISIBLE);
    //actionButtons.removeView(bEffectAction);

    bPresetAction = (Button) actionButtons.findViewById(R.id.button_preset_action);
    bPresetAction.setOnClickListener(this);

    bProgrammerAction = (Button) actionButtons.findViewById(R.id.button_programmer_action);
    bProgrammerAction.setOnClickListener(this);

    updateStateSelected();
    return actionButtons;
}

From source file:blackman.matt.infinitebrowser.NavigationDrawerFragment.java

/**
 * Called when the fragments view is being created. Handled inflating the view and assigning
 * values./*from w w  w. jav a2  s .co m*/
 *
 * @param inflater inflater sent in from parent activity.
 * @param container The container that the fragment will go in.
 * @param savedInstanceState the instance state of the activity.
 * @return returns this fragments newly created view.
 */
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    LinearLayout drawerview = (LinearLayout) inflater.inflate(R.layout.fragment_navigation_drawer, container,
            false);

    mDrawerListView = (ListView) drawerview.findViewById(R.id.navigation_drawer_listview);

    mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectItem(position);
        }
    });

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    Boolean ageAccept = preferences.getBoolean("age_guard_accept", false);

    if (ageAccept) {
        setUpListAdapter();
    }

    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
    return drawerview;
}