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:org.openmrs.mobile.activities.dialog.CustomFragmentDialog.java

public TextView addTextField(String message) {
    LinearLayout field = (LinearLayout) mInflater.inflate(R.layout.openmrs_text_view_field, null);
    TextView textView = (TextView) field.findViewById(R.id.openmrsTextView);
    textView.setText(message);//from w ww.  ja  v  a2 s.  com
    textView.setSingleLine(false);
    FontsUtil.setFont(textView, FontsUtil.OpenFonts.OPEN_SANS_ITALIC);
    mFieldsLayout.addView(field, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    return textView;
}

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

public TextView addTitleBar(String title) {
    LinearLayout field = (LinearLayout) mInflater.inflate(R.layout.openmrs_title_view_field, null);
    TextView textView = (TextView) field.findViewById(R.id.openmrsTitleView);
    textView.setText(title);/* w  w  w. ja v a  2 s .  c  om*/
    textView.setSingleLine(true);
    mFieldsLayout.addView(field, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    return textView;
}

From source file:com.mikepenz.lollipopshowcase.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    //supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set explode animation when enter and exit the activity
    //Utils.configureWindowEnterExitTransition(getWindow());

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from   w w  w . j a v a  2s .c  o  m*/
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Handle DrawerLayout
    DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer);

    // Handle ActionBarDrawerToggle
    ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar,
            R.string.drawer_open, R.string.drawer_close);
    actionBarDrawerToggle.syncState();

    // Handle different Drawer States :D
    mDrawerLayout.setDrawerListener(actionBarDrawerToggle);

    // Handle DrawerList
    LinearLayout mDrawerList = (LinearLayout) findViewById(R.id.drawerList);

    // Init DrawerElems NOTE Just don't do this in a live app :D
    final SharedPreferences pref = getSharedPreferences("com.mikepenz.applicationreader", 0);
    ((Switch) mDrawerList.findViewById(R.id.drawer_autoupload))
            .setChecked(pref.getBoolean("autouploadenabled", false));
    ((Switch) mDrawerList.findViewById(R.id.drawer_autoupload))
            .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    SharedPreferences.Editor editor = pref.edit();
                    editor.putBoolean("autouploadenabled", isChecked);
                    editor.apply();
                }
            });

    mDrawerList.findViewById(R.id.drawer_opensource).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Create an intent with context and the Activity class
            Intent i = new Intent(getApplicationContext(), LibsActivity.class);
            //Pass the fields of your application to the lib so it can find all external lib information
            i.putExtra(Libs.BUNDLE_FIELDS, Libs.toStringArray(R.string.class.getFields()));

            //Display the library version (OPTIONAL)
            i.putExtra(Libs.BUNDLE_VERSION, false);
            //Display the library license (OPTIONAL
            i.putExtra(Libs.BUNDLE_LICENSE, true);

            //Set a title (OPTIONAL)
            i.putExtra(Libs.BUNDLE_TITLE, getString(R.string.drawer_opensource));

            //Pass your theme (OPTIONAL)
            i.putExtra(Libs.BUNDLE_THEME, R.style.AboutTheme);

            //start the activity
            startActivity(i);
        }
    });
    ((ImageView) mDrawerList.findViewById(R.id.drawer_opensource_icon)).setImageDrawable(
            new IconicsDrawable(this, FontAwesome.Icon.faw_github).colorRes(R.color.secondary).actionBarSize());

    // Fab Button
    fabButton = (ImageButton) findViewById(R.id.fab_button);
    fabButton.setImageDrawable(
            new IconicsDrawable(this, FontAwesome.Icon.faw_upload).color(Color.WHITE).actionBarSize());
    fabButton.setOnClickListener(fabClickListener);
    Utils.configureFab(fabButton);

    RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.list);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setItemAnimator(new RebountItemAnimator());
    mAdapter = new ApplicationAdapter(new ArrayList<AppInfo>(), R.layout.row_application, MainActivity.this);
    mRecyclerView.setAdapter(mAdapter);

    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            new InitializeApplicationsTask().execute();
        }
    });

    new InitializeApplicationsTask().execute();
}

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

private RecyclerView addRecycleView(List<Patient> patientsList, Patient newPatient) {
    LinearLayout field = (LinearLayout) mInflater.inflate(R.layout.openmrs_recycle_view, null);
    RecyclerView recyclerView = (RecyclerView) field.findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(new SimilarPatientsRecyclerViewAdapter((getActivity()), patientsList, newPatient));
    mFieldsLayout.addView(field);// w w w  . ja v  a  2s  . c  om
    recyclerView.setHasFixedSize(true);
    return recyclerView;
}

From source file:com.linangran.tgfcapp.activities.MainActivity.java

private void inflateForumList(List<ForumBasicData> list, LinearLayout layout) {
    if (list == null || list.size() == 0) {
        return;//w w  w  .j  a v  a2s  .com
    }
    LayoutInflater inflater = getLayoutInflater();
    for (int i = 0; i < list.size(); i++) {
        LinearLayout textLinearLayout = (LinearLayout) inflater.inflate(R.layout.forum_list_item, null);
        layout.addView(textLinearLayout);
        TextView textView = (TextView) textLinearLayout.findViewById(R.id.forum_list_item_textview);
        textView.setText(list.get(i).name);
        textView.setTag(list.get(i));
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ForumBasicData forumBasicData = (ForumBasicData) view.getTag();
                MainActivity.this.drawerLayout.closeDrawers();
                MainActivity.this.drawerLayout.post(new Runnable() {
                    @Override
                    public void run() {
                        MainActivity.this.drawerToggle.syncState();
                    }
                });
                MainActivity.this.forumListFragment.reload(forumBasicData);
            }
        });
    }
}

From source file:com.foodie.app.fragment.LocationFragment.java

@Nullable
@Override/*  ww w  .j  a  va2 s .co m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LinearLayout view = (LinearLayout) inflater.inflate(R.layout.fragment_location, container, false);
    restaurantListView = (RecyclerView) view.findViewById(R.id.recyclerview);
    restaurantListView.setItemAnimator(new DefaultItemAnimator());
    progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
    sr = (SwipeRefreshLayout) view.findViewById(R.id.sr);
    return view;
}

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

/**
 * Called when this {@link android.support.v4.app.DialogFragment} is being created
 */// www  .j a v  a  2s. c o  m
@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:com.kccomy.orgar.ui.note.NoteFragment.java

@Override
public void onNodeLongClick(View view, final TreeNode treeNode, final int position) {
    LinearLayout menuLayout = (LinearLayout) view.findViewById(R.id.item_org_tree_llayout_menu);
    menuLayout.setVisibility(View.VISIBLE);

    ImageButton imgBtnEdit = (ImageButton) menuLayout.findViewById(R.id.item_org_tree_menu_ibtn_edit);
    imgBtnEdit.setOnClickListener(new View.OnClickListener() {
        @Override//from   ww  w  .  j  av a 2  s . c  o m
        public void onClick(View view) {
            presenter.edit(treeNode);
        }
    });

    ImageButton imageBtnAddNode = (ImageButton) menuLayout.findViewById(R.id.item_org_tree_menu_ibtn_add_node);
    imageBtnAddNode.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            presenter.addNode(treeNode);
        }
    });

    ImageButton imageButtonAddSub = (ImageButton) menuLayout
            .findViewById(R.id.item_org_tree_menu_ibtn_add_subnode);
    imageButtonAddSub.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            presenter.addSubNode(treeNode);
        }
    });

    ImageButton imageBtnDelete = (ImageButton) menuLayout.findViewById(R.id.item_org_tree_menu_ibtn_delete);
    imageBtnDelete.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            presenter.delete(treeNode);
        }
    });

}

From source file:com.gizwits.gizdataaccesssdkdemo.activitys.MainActivity.java

/**
 * .//from   w w  w.jav  a2  s . c  o  m
 * 
 * @return the dialog
 */
public Dialog dateTimePicKDialog() {
    DisplayMetrics dm = new DisplayMetrics();
    dm = this.getResources().getDisplayMetrics();
    int screenWidth = dm.widthPixels;
    int screenHeight = dm.heightPixels;
    LinearLayout dateTimeLayout = (LinearLayout) this.getLayoutInflater().inflate(R.layout.dialog_time, null);

    etLimit = (EditText) dateTimeLayout.findViewById(R.id.etLimit);
    etSkip = (EditText) dateTimeLayout.findViewById(R.id.etSkip);
    etYearStart = (EditText) dateTimeLayout.findViewById(R.id.etYearStart);
    etYearEnd = (EditText) dateTimeLayout.findViewById(R.id.etYearEnd);
    etMonStart = (EditText) dateTimeLayout.findViewById(R.id.etMonStart);
    etMonEnd = (EditText) dateTimeLayout.findViewById(R.id.etMonEnd);
    etDayStart = (EditText) dateTimeLayout.findViewById(R.id.etDayStart);
    etDayEnd = (EditText) dateTimeLayout.findViewById(R.id.etDayEnd);
    etHourStart = (EditText) dateTimeLayout.findViewById(R.id.etHourStart);
    etHourEnd = (EditText) dateTimeLayout.findViewById(R.id.etHourEnd);
    etMinStart = (EditText) dateTimeLayout.findViewById(R.id.etMinStart);
    etMinEnd = (EditText) dateTimeLayout.findViewById(R.id.etMinEnd);
    etSecStart = (EditText) dateTimeLayout.findViewById(R.id.etSecStart);
    etSecEnd = (EditText) dateTimeLayout.findViewById(R.id.etSecEnd);
    btnStartLoad = (Button) dateTimeLayout.findViewById(R.id.btnStartLoad);
    btnStartLoad.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            loadData();

        }
    });

    dialog = new Dialog(this);
    WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
    params.width = (int) (screenWidth * 0.8);
    params.height = screenHeight / 5;
    params.width = (int) (screenWidth * 0.8);
    params.height = (int) (screenHeight * 0.8);
    dialog.getWindow().setAttributes(params);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(dateTimeLayout);

    return dialog;
}

From source file:ca.marcmeszaros.papyrus.browser.BooksBrowser.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        switch (requestCode) {
        // LOAN A BOOK
        case 1001:

            // there are sufficient copies of the book to lend
            if (canLoanBook()) {
                loanData = data;/*from   w w w  .j a  va  2 s  . c  om*/

                // set default due date
                final Calendar c = Calendar.getInstance();
                c.setTimeInMillis(System.currentTimeMillis() + (1000 * 60 * 60 * 24 * 14));
                int mYear = c.get(Calendar.YEAR);
                int mMonth = c.get(Calendar.MONTH);
                int mDay = c.get(Calendar.DAY_OF_MONTH);

                // create the custom dialog title view block
                LinearLayout linearLayout = (LinearLayout) getLayoutInflater()
                        .inflate(R.layout.datepickerdialog_customtitle_twoline, null);
                TextView title = (TextView) linearLayout
                        .findViewById(R.id.DatePickerDialog_customTitle_twoline_title);
                TextView titleDescription = (TextView) linearLayout
                        .findViewById(R.id.DatePickerDialog_customTitle_twoline_description);

                // set the text
                title.setText(R.string.AlertDialog_LoanReturnDateDialog_title);
                titleDescription.setText(R.string.AlertDialog_LoanReturnDateDialog_titleDescription);

                // create the dialog with the custom header and display it
                DatePickerDialog dialog = new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
                dialog.setCustomTitle(linearLayout);
                dialog.show();
            } else {
                // there are no more copies left in the library
                Toast.makeText(this, getString(R.string.BooksBrowser_toast_allCopiesLentOut), Toast.LENGTH_LONG)
                        .show();
            }

            break;
        }

    } else {
        // gracefully handle failure
        // Log.w(DEBUG_TAG, "resultWarning: activity result not ok");
    }
}