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:au.com.wallaceit.reddinator.SimpleTabsWidget.java

private void insertTab(int index, String text) {

    TabClickListener clickListener = new TabClickListener(index);
    LinearLayout tabContainer = (LinearLayout) inflater.inflate(R.layout.tab, tabWidget, false);
    tabContainer.setOnClickListener(clickListener);

    TextView tabText = (TextView) tabContainer.findViewById(R.id.tab_text);
    tabText.setText(text);/*from  ww  w.  j a v  a  2  s. co  m*/
    tabText.setTextColor(colors[0]);
    tabItems.add(tabText);

    LinearLayout indicator = (LinearLayout) tabContainer.findViewById(R.id.tab_indicator);
    indicator.setBackgroundColor(colors[1]);
    indicatorItems.add(indicator);

    tabContainer.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1));
    tabWidget.addView(tabContainer);
}

From source file:com.dicent.DiceFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dice_fragment, container, false);
    enabledCheckbox = (CheckBox) layout.findViewById(R.id.diceEndabledCheckBox);
    enabledCheckbox.setOnCheckedChangeListener(new OnEnabledListener());
    enabledCheckbox.setText(checkboxText);
    diceTable = (TableLayout) layout.findViewById(R.id.diceTable);
    refreshCheckbox();/*from w  w w . j a va2  s . c  om*/

    return layout;
}

From source file:com.tmall.ultraviewpager.sample.UltraPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(container.getContext())
            .inflate(R.layout.layout_child, null);
    //new LinearLayout(container.getContext());
    TextView textView = (TextView) linearLayout.findViewById(R.id.pager_textview);
    textView.setText(position + "");
    linearLayout.setId(R.id.item_id);//from   ww w.  j  a  v  a  2 s.  com
    switch (position) {
    case 0:
        linearLayout.setBackgroundColor(Color.parseColor("#2196F3"));
        break;
    case 1:
        linearLayout.setBackgroundColor(Color.parseColor("#673AB7"));
        break;
    case 2:
        linearLayout.setBackgroundColor(Color.parseColor("#009688"));
        break;
    case 3:
        linearLayout.setBackgroundColor(Color.parseColor("#607D8B"));
        break;
    case 4:
        linearLayout.setBackgroundColor(Color.parseColor("#F44336"));
        break;
    }
    container.addView(linearLayout);
    //        linearLayout.getLayoutParams().width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, container.getContext().getResources().getDisplayMetrics());
    //        linearLayout.getLayoutParams().height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 400, container.getContext().getResources().getDisplayMetrics());
    return linearLayout;
}

From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.DayFragment.java

public void inflateLayout(int iPos) {

    String sIdSubject = Session.getSingleInstance().getDatabaseHandler().getSubjects().get(iPos).getsId();

    // String sIdSubject = Session.getSingleInstance().getActivity(iPos).getId_subject();        
    long lDuration = Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sIdSubject);

    // List of activities to inflate history
    List<ActividadDb> lADb = Session.getSingleInstance().getDatabaseHandler().getActivities(sIdSubject);

    // Duration/*from   w  w  w  .  j  a  v a 2s  .c o m*/
    DateUtils du = new DateUtils();
    TextView t = (TextView) rootView.findViewById(R.id.tvDuration);
    t.setText(du.duration(lDuration));

    // Time picker
    TimePicker timePicker = (TimePicker) rootView.findViewById(R.id.tpTask);
    timePicker.setIs24HourView(true);
    timePicker.setCurrentHour(0);
    timePicker.setCurrentMinute(45);

    // Button image view   
    ImageView iv = (ImageView) rootView.findViewById(R.id.ivActionActivity);
    int currentStatus = Session.getSingleInstance().getActivity(iPos).getStatus();
    if (currentStatus == ActivitySession.STATUS_STOPPED) {
        Drawable d = getResources().getDrawable(R.drawable.play);
        iv.setImageDrawable(d);
    } else {
        Drawable d = getResources().getDrawable(R.drawable.stop);
        iv.setImageDrawable(d);
    }

    // History      
    if (lADb.size() != 0) {

        LinearLayout llHistory = (LinearLayout) rootView.findViewById(R.id.llHistory);
        TextView tvHeader = (TextView) llHistory.findViewById(R.id.tvHeaderHisory);
        tvHeader.setVisibility(View.VISIBLE);

        for (int i = 0; i < lADb.size(); i++) {

            ActividadDb adb = lADb.get(i);

            LinearLayout llCheckItemWrapper = (LinearLayout) mInflater.inflate(R.layout.check_item, null);
            // Passing order as param so it can be removed
            llCheckItemWrapper.setTag(i);

            LinearLayout liContent = (LinearLayout) llCheckItemWrapper.getChildAt(0);

            TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp);
            tvTimeStamp.setText(Constants.TIME_FORMAT.format(adb.getlDateCheckIn()));
            // Passing checkin time in mills as tag
            tvTimeStamp.setTag(Long.valueOf(adb.getlDateCheckIn()));

            TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration);
            tvDurRecord.setText(" [" + du.duration(adb.getlDateCheckIn(), adb.getlDateCheckOut()) + "]");
            // Passing subject id as parameter        
            tvDurRecord.setTag(adb.getsIdSubject());

            llHistory.addView(mInflater.inflate(R.layout.tag_divider, llHistory, false), 1);
            llHistory.addView(llCheckItemWrapper, 2);

        }

    }

}

From source file:com.pixate.freestyle.fragment.IconsFragment.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub

    /** LinearLayout for each grid view icon item */
    LinearLayout iconLayout;
    if (convertView == null) {
        iconLayout = (LinearLayout) mInflater.inflate(R.layout.view_icon_item, null);
    } else {//  w  w w.j av  a  2 s. c  o m
        iconLayout = (LinearLayout) convertView;
    }

    ((ImageView) iconLayout.findViewById(R.id.image_view_icon)).setImageResource(
            mContext.getResources().getIdentifier(icons[position], "drawable", mContext.getPackageName()));
    ((TextView) iconLayout.findViewById(R.id.text_view_name)).setText(icons[position]);

    return iconLayout;
}

From source file:com.barcamppenang2013.tabfragment.HomeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (scrollView != null) {
        ViewGroup parent = (ViewGroup) scrollView.getParent();
        if (parent != null)
            parent.removeView(scrollView);
    }//from   w  w  w .j  a v a  2  s  .  co m
    scrollView = (ScrollView) inflater.inflate(R.layout.home_layout, container, false);
    LinearLayout linearLayout = (LinearLayout) scrollView.findViewById(R.id.home_linear_layout);
    // linearLayout.setBackgroundColor(Color.WHITE);
    mTextViewDay = (TextView) linearLayout.findViewById(R.id.count_down_day);
    mTextViewHour = (TextView) linearLayout.findViewById(R.id.count_down_hour);
    mImageViewClickMe = (Button) linearLayout.findViewById(R.id.map_fullscreen_button);
    mImageViewClickMe.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (getActivity() == null)
                return;
            MainActivity fca = (MainActivity) getActivity();
            fca.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            fca.switchContent(new MapFragment());
        }
    });
    // mTextView.setBackgroundResource(R.drawable.info_countdown);
    Date date = new Date(113, 6, 27); // 2013/July/27
    // year the year, 0 is 1900.
    // month the month, 0 - 11.
    // day the day of the month, 1 - 31.
    long dtMili = System.currentTimeMillis();
    Date dateNow = new Date(dtMili);
    long remain = date.getTime() - dateNow.getTime();

    new CountDownTimer(remain, 1000) {

        public void onTick(long millisUntilFinished) {
            // mTextView.setText("seconds remaining: " + millisUntilFinished
            // / 1000);
            mTextViewDay.setText(timeDay(millisUntilFinished / 1000));
            mTextViewHour.setText(timeHour(millisUntilFinished / 1000));
        }

        public void onFinish() {
            // mTextView.setText("done!");
        }
    }.start();

    return scrollView;
}

From source file:com.pepperonas.truthordare.fragments.FragmentMultiplayer.java

@Override
public boolean onMenuItemClick(MenuItem item) {
    Log.d(TAG, "onMenuItemClick  " + "");

    if (mLlm.getChildCount() < 2) {
        ToastUtils.toastShort(R.string.at_least_two_players);
        return false;
    }/*w  w w . java2s  . c  om*/

    mMain.getPlayers().clear();

    Player tmpPlayer;

    for (int i = 0; i < mLlm.getChildCount(); i++) {

        if (mLlm.getChildAt(i) instanceof Button)
            continue;

        LinearLayout playerLayout = (LinearLayout) mLlm.getChildAt(i);

        EditText etName = (EditText) playerLayout.findViewById(R.id.et_name);
        EditText etJokers = (EditText) playerLayout.findViewById(R.id.et_jokers);
        RadioButton radioFemale = (RadioButton) playerLayout.findViewById(R.id.rb_female);

        if (ensureInput(etName, etJokers))
            return false;

        mMain.getPlayers()
                .add(tmpPlayer = new Player(mMain.getPlayers().size(), etName.getText().toString(),
                        Integer.parseInt(etJokers.getText().toString()),
                        radioFemale.isChecked() ? Gender.FEMALE : Gender.MALE));

        mMain.getDatabase().addPlayer(tmpPlayer.getId(), tmpPlayer.getName(), tmpPlayer.getGender(), true);
    }

    showPlayerLog();

    mMain.makeFragmentTransaction(FragmentSelectAction.newInstance(0));
    return true;
}

From source file:org.ewicom.pps.unitinfo.TabLeadersFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    personDataSource = new PersonDataSource(getActivity());
    personDataSource.open();/*from  ww  w.jav a 2 s . com*/

    LinearLayout leadersLL = (LinearLayout) getView().findViewById(R.id.ll_leaders);

    List<Person> persons = new ArrayList<Person>();
    persons = personDataSource.getPersonsByUnitId(unitID);

    if (persons != null && !persons.isEmpty()) {
        Iterator<Person> iterator = persons.iterator();

        while (iterator.hasNext()) {

            final Person person = iterator.next();

            LinearLayout personLL = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.person_ll,
                    null);

            TextView positionTV = (TextView) personLL.findViewById(R.id.text_personposition);
            TextView nameTV = (TextView) personLL.findViewById(R.id.text_personname);
            TextView phoneTV = (TextView) personLL.findViewById(R.id.text_personphone);
            TextView emailTV = (TextView) personLL.findViewById(R.id.text_personemail);

            positionTV.setText(person.getPosition());
            nameTV.setText(person.getPerson());
            phoneTV.setText(person.getPhone());
            emailTV.setText(person.getEmail());

            Linkify.addLinks(phoneTV, Linkify.PHONE_NUMBERS);
            Linkify.addLinks(emailTV, Linkify.EMAIL_ADDRESSES);

            TextView saveContactLink = (TextView) getActivity().getLayoutInflater()
                    .inflate(R.layout.textview_link_savecontact, null);
            LayoutParams linkParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            personLL.addView(saveContactLink, linkParam);
            saveContactLink.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    Intent saveContactIntent = new Intent(Intents.Insert.ACTION);
                    saveContactIntent.setType(ContactsContract.RawContacts.CONTENT_TYPE);

                    saveContactIntent.putExtra(Intents.Insert.NAME, person.getPerson());
                    saveContactIntent.putExtra(Intents.Insert.JOB_TITLE, person.getPosition());
                    saveContactIntent.putExtra(Intents.Insert.PHONE, person.getPhone());
                    saveContactIntent.putExtra(Intents.Insert.EMAIL, person.getEmail());

                    startActivity(saveContactIntent);
                }
            });

            leadersLL.addView(personLL);

        }

    }

}

From source file:com.example.android.tictactoe.library.GameFragment.java

/**
 * Called when the activity is first created.
 *///from  w w w . j  a  v  a 2s  .  c  o m
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    /*
     * IMPORTANT: all resource IDs from this library will eventually be merged
     * with the resources from the main project that will use the library.
     *
     * If the main project and the libraries define the same resource IDs,
     * the application project will always have priority and override library resources
     * and IDs defined in multiple libraries are resolved based on the libraries priority
     * defined in the main project.
     *
     * An intentional consequence is that the main project can override some resources
     * from the library.
     * (TODO insert example).
     *
     * To avoid potential conflicts, it is suggested to add a prefix to the
     * library resource names.
     */
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.lib_game, container, false);

    mGameView = (GameView) layout.findViewById(R.id.game_view);
    mInfoView = (TextView) layout.findViewById(R.id.info_turn);
    mButtonNext = (Button) layout.findViewById(R.id.next_turn);

    mGameView.setFocusable(true);
    mGameView.setFocusableInTouchMode(true);
    mGameView.setCellListener(new MyCellListener());

    mButtonNext.setOnClickListener(new MyButtonListener());

    return layout;
}

From source file:com.mobicage.rogerthat.FriendDetailOrInviteActivity.java

private void updateView() {
    final ImageView image = (ImageView) findViewById(R.id.friend_avatar);

    if (mFriend == null) {
        image.setVisibility(View.INVISIBLE);
        return;/* ww  w  .  j a  v a2 s.  com*/
    }
    image.setVisibility(View.VISIBLE);
    final TextView nameView = (TextView) findViewById(R.id.friend_name);

    if (mFriend.avatar == null) {
        image.setImageBitmap(mFriendsPlugin.getMissingFriendAvatarBitmap());
    } else {
        final Bitmap avatarBitmap = BitmapFactory.decodeByteArray(mFriend.avatar, 0, mFriend.avatar.length);
        image.setImageBitmap(ImageHelper.getRoundedCornerAvatar(avatarBitmap));
    }

    setTitle(mFriend.getDisplayName());
    nameView.setText(mFriend.getDisplayName());
    nameView.setTextColor(ContextCompat.getColor(this, android.R.color.primary_text_light));

    final LinearLayout profileDataContainer = (LinearLayout) findViewById(R.id.profile_data);
    if (AppConstants.PROFILE_DATA_FIELDS.length > 0) {
        profileDataContainer.removeAllViews();
        profileDataContainer.setVisibility(View.VISIBLE);
        Map<String, String> profileData = mFriend.getProfileDataDict();
        for (String k : AppConstants.PROFILE_DATA_FIELDS) {
            final LinearLayout ll = (LinearLayout) View.inflate(this, R.layout.profile_data_detail, null);
            final TextView tvKey = (TextView) ll.findViewById(R.id.profile_data_detail_key);
            final TextView tvVal = (TextView) ll.findViewById(R.id.profile_data_detail_value);

            String v = profileData == null ? null : profileData.get(k);
            if (v == null) {
                v = getString(R.string.unknown);
            }
            tvKey.setText(k);
            tvKey.setTextColor(LookAndFeelConstants.getPrimaryColor(this));
            tvVal.setText(v);

            profileDataContainer.addView(ll);
        }
    } else {
        profileDataContainer.setVisibility(View.GONE);
    }
}