Example usage for android.widget LinearLayout setTag

List of usage examples for android.widget LinearLayout setTag

Introduction

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

Prototype

public void setTag(final Object tag) 

Source Link

Document

Sets the tag associated with this view.

Usage

From source file:com.example.android.animationsdemo.BoardFragment.java

public void createCol() {
    int colNo = board.getColNo();
    Log.i("colNo", "colNo=" + colNo);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/*from  w  w w. j  a  v a2s. com*/
    int width = size.x;
    int height = size.y;
    Log.i("conditions", "codition start=" + Math.max(0, start) + "\n check = "
            + Math.min(start + MAX_COL_DISPLAYED, board.getColNo()) + "in createCOl");
    for (int i = Math.max(0, start); i < Math.min(start + MAX_COL_DISPLAYED, board.getColNo()); i++) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View columnView = inflater.inflate(R.layout.columns_layout, null, false);
        LinearLayout ll = (LinearLayout) columnView.findViewById(R.id.ll);
        ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT, 1.0f / MAX_COL_DISPLAYED));
        TextView tv = (TextView) columnView.findViewById(R.id.tv);
        tv.setText(board.getColName(i));
        Button addCard = (Button) columnView.findViewById(R.id.addCard);
        LinearLayout cardContainerLayout = (LinearLayout) columnView.findViewById(R.id.cardContainer);
        cardContainerLayout.setTag("col" + board.getColName(i));
        cardContainerLayout.setId(position);
        cardContainerLayout.setMinimumHeight(height);
        cardContainerLayout.setMinimumWidth(width / MAX_COL_DISPLAYED);
        Log.i("Drag", "Calling drag constructor ");
        cardContainerLayout.setOnDragListener(new MyDragListener(rootViewGroup));
        Log.i("Drag", "Drag Constructor Called ");
        addCard.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                BoardFragment.this.addItem(view);
            }
        });
        //cardContainerLayout.setLayoutTransition(new LayoutTransition());

        rootViewGroup.addView(columnView);
    }
}

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.ja  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.melvin.android.base.common.ui.TabPageIndicator.java

private void addTab(String text, int index) {
    // Workaround for not being able to pass a defStyle on pre-3.0
    RFileUtil fileUtil = RFileUtil.getInstance(this.mContext);
    int layoutid = fileUtil.getLayoutValue("tab_item_layout");
    LinearLayout linear = (LinearLayout) mInflater.inflate(layoutid, null);
    linear.setFocusable(true);/*www.ja v a  2 s .  c o m*/
    linear.setOnClickListener(mTabClickListener);
    TextView vv = (TextView) linear.findViewById(android.R.id.text1);
    vv.setText(text);
    linear.setTag(index);
    mTabLayout.addView(linear, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));
}

From source file:utils.widget.vpi_lib.TabPageIndicator_Custom.java

@SuppressLint("InflateParams")
private void addTab(int index, CharSequence text, int iconResId, String url) {
    // TODO/*from w ww . java  2s .  com*/
    final TabView tabView = new TabView(getContext());
    tabView.mIndex = index;
    LinearLayout linearLayout = new LinearLayout(getContext());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setTag(index);
    linearLayout.setFocusable(true);
    linearLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            LinearLayout tabView = (LinearLayout) v;
            final int oldSelected = mViewPager.getCurrentItem();
            final int newSelected = Integer.valueOf(tabView.getTag().toString());
            mViewPager.setCurrentItem(newSelected);
            if (oldSelected == newSelected && mTabReselectedListener != null) {
                mTabReselectedListener.onTabReselected(newSelected);
            }
        }
    });

    parentView = LayoutInflater.from(getContext()).inflate(R.layout.vpi_tap_custom, null);
    ImageView img = (ImageView) parentView.findViewById(R.id.tabImage);
    // img.setImageResource(iconResId);
    /*
     * ProgressBar pbBar = (ProgressBar)
     * view.findViewById(R.id.progressBar_tab_custom);
     */
    // LinearLayout layout = (LinearLayout)
    // view.findViewById(R.id.vpi_custom_layout);
    TextView txtTitle = (TextView) parentView.findViewById(R.id.vpi_custom_txt_Title);
    TextView txtBottom = (TextView) parentView.findViewById(R.id.vpi_custom_txt_btm);
    // TODO
    // LinearLayout.LayoutParams layoutParams = new
    // LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    // layout.setLayoutParams(layoutParams);

    txtTitle.setText(text);
    txtTitle.setTextColor(getResources().getColor(R.color.vpi_non_focus));
    txtBottom.setBackgroundColor(getResources().getColor(R.color.vpi_non_focus));

    /*
     * AQuery aq = new AQuery(getContext());
     * aq.id(img).progress(pbBar).image(url, false, true, 0,
     * R.drawable.img_default_category, new BitmapAjaxCallback() {
     * 
     * @SuppressLint("NewApi") @SuppressWarnings("deprecation")
     * 
     * @Override protected void callback(String url, ImageView iv, Bitmap
     * bm, AjaxStatus status) { int sdk = android.os.Build.VERSION.SDK_INT;
     * if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
     * iv.setBackgroundDrawable(new
     * BitmapDrawable(getContext().getResources(), bm)); } else {
     * iv.setBackground(new BitmapDrawable(getContext().getResources(),
     * bm)); } } });
     */

    linearLayout.addView(parentView);
    linearLayout.addView(tabView);

    mTabLayout.addView(linearLayout, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 1));
}

From source file:com.yanzhenjie.recyclerview.swipe.SwipeMenuView.java

public void createMenu(SwipeMenu swipeMenu, SwipeSwitch swipeSwitch,
        SwipeMenuItemClickListener swipeMenuItemClickListener,
        @SwipeMenuRecyclerView.DirectionMode int direction) {
    removeAllViews();//  w w w  . j ava  2 s . c o  m

    this.mSwipeSwitch = swipeSwitch;
    this.mItemClickListener = swipeMenuItemClickListener;
    this.mDirection = direction;

    List<SwipeMenuItem> items = swipeMenu.getMenuItems();
    for (int i = 0; i < items.size(); i++) {
        SwipeMenuItem item = items.get(i);

        LayoutParams params = new LayoutParams(item.getWidth(), item.getHeight());
        params.weight = item.getWeight();
        LinearLayout parent = new LinearLayout(getContext());
        parent.setId(i);
        parent.setGravity(Gravity.CENTER);
        parent.setOrientation(VERTICAL);
        parent.setLayoutParams(params);
        ViewCompat.setBackground(parent, item.getBackground());
        parent.setOnClickListener(this);
        addView(parent);

        SwipeMenuBridge menuBridge = new SwipeMenuBridge(mDirection, i, mSwipeSwitch, parent);
        parent.setTag(menuBridge);

        if (item.getImage() != null) {
            ImageView iv = createIcon(item);
            menuBridge.mImageView = iv;
            parent.addView(iv);
        }

        if (!TextUtils.isEmpty(item.getText())) {
            TextView tv = createTitle(item);
            menuBridge.mTextView = tv;
            parent.addView(tv);
        }
    }
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

private LinearLayout make_Active_Tab(String text, Drawable dr) {

    LinearLayout ll = new LinearLayout(this);
    ll.setPadding(0, 0, 2, 1);//from   ww w.j a  v a  2  s . c o  m
    ll.setBackgroundColor(Color.GRAY);

    ll.setTag("ll");
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setLayoutParams(
            new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1));

    //------ Text 
    TextView tv = new TextView(this);
    tv.setBackgroundColor(Color.TRANSPARENT);
    tv.setTag("tv");
    ll.addView(tv);

    // ------ hbar
    View hbar = new View(this);
    hbar.setTag("hbar");
    hbar.setLayoutParams(
            new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10));

    ll.addView(hbar);

    ////////////////////////////////////////
    return ActivateColorize(ll, text, dr);
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

private LinearLayout make_Inactive_Tab(String text, Drawable dr) {

    LinearLayout ll = new LinearLayout(this);

    ll.setPadding(0, 0, 2, 1);//from www  .  j a  v a 2s .  c o m

    ll.setBackgroundColor(Color.GRAY);

    ll.setTag("ll");
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setLayoutParams(
            new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1));

    //------ Text 
    TextView tv = new TextView(this);
    tv.setBackgroundColor(Color.TRANSPARENT);
    tv.setTag("tv");
    ll.addView(tv);

    // ------ hbar
    View hbar = new View(this);
    hbar.setTag("hbar");
    hbar.setLayoutParams(
            new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10));

    ll.addView(hbar);

    /////////////////////////////////////
    return InActivateColorize(ll, text, dr);
}

From source file:com.cssweb.android.quote.QHSCGridActivity.java

protected void initBlankTable(int pageNum, int length, boolean nameOrCodeFlag) throws JSONException {
    LinearLayout localLinearLayout1 = (LinearLayout) this.findViewById(R.id.zr_htable_lock1);
    LinearLayout localLinearLayout2 = (LinearLayout) this.findViewById(R.id.zr_htable_lock2);
    LinearLayout localLinearLayout = (LinearLayout) this.findViewById(R.id.zr_htable_linearlayout);

    this.mLinerLock = localLinearLayout1;
    this.mLinerLock2 = localLinearLayout2;
    this.mLinerHScroll = localLinearLayout;
    this.mLinerLock.removeAllViews();
    this.mLinerLock2.removeAllViews();
    this.mLinerHScroll.removeAllViews();

    this.nameOrCodeFlag = nameOrCodeFlag;

    if (nameOrCodeFlag) {// ?(????)
        localLinearLayout2.setVisibility(View.GONE);
        if (nameOrcode)
            AddViewItem(Utils.getTextColor(mContext, 0), mLinerLock, -100, 0, 0, true);
        else//ww w . j  a va2s.c o  m
            AddViewItem(Utils.getTextColor(mContext, 0), mLinerLock, -100, 0, 0, true);
    } else {
        AddViewItem(Utils.getTextColor(mContext, 0), mLinerLock, 0, 0, 0, true);
        AddViewItem(Utils.getTextColor(mContext, 0), mLinerLock2, -1, 0, 0, true);
    }

    LinearLayout l1 = new LinearLayout(this);
    for (int i = 2; i < length; i++) {
        if (i == length - 1)
            AddViewItem(Utils.getTextColor(mContext, 0), l1, -i, 100, 0, true);
        else
            AddViewItem(Utils.getTextColor(mContext, 0), l1, -i, i - 1, 0, true);
    }
    l1.setTag(0);
    mLinerHScroll.addView(l1);
    for (int i = 1; i <= pageNum; i++) {
        if (nameOrCodeFlag) {
            localLinearLayout2.setVisibility(View.GONE);
            if (nameOrcode)
                AddViewItem(Utils.getTextColor(mContext, 1), mLinerLock, i, 0, i, true);
            else
                AddViewItem(Utils.getTextColor(mContext, 1), mLinerLock, i, 0, i, true);
        } else {
            AddViewItem(Utils.getTextColor(mContext, 1), mLinerLock, i, 0, i, true);
            AddViewItem(Utils.getTextColor(mContext, 1), mLinerLock2, i, 0, i, true);
        }

        l1 = new LinearLayout(this);
        l1.setTag(i);
        for (int j = 1; j <= length - 2; j++) {
            if (j == length - 2)
                AddViewItem(Utils.getTextColor(mContext, 0), l1, i, 100, i, true);
            else
                AddViewItem(Utils.getTextColor(mContext, 0), l1, i, j, i, true);
        }
        mLinerHScroll.addView(l1);
    }
}

From source file:com.quarterfull.newsAndroid.ListView.SubscriptionExpandableListAdapter.java

@Override
public View getGroupView(final int groupPosition, final boolean isExpanded, View convertView,
        ViewGroup parent) {/*  w w w.  ja v  a 2s.  com*/

    GroupHolder viewHolder;
    final AbstractItem group = (AbstractItem) getGroup(groupPosition);

    if (convertView == null) {
        LinearLayout view = new LinearLayout(mContext);
        convertView = inflater.inflate(R.layout.subscription_list_item, view, true);
        viewHolder = new GroupHolder(convertView);
        view.setTag(viewHolder);
    } else {
        viewHolder = (GroupHolder) convertView.getTag();
    }

    viewHolder.txt_Summary.setText(group.header);
    viewHolder.listItemLayout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            long idFeed = group.id_database;
            boolean skipFireEvent = false;

            if (group instanceof ConcreteFeedItem) {
                fireListTextClicked(idFeed, false, (long) ITEMS_WITHOUT_FOLDER.getValue());
                skipFireEvent = true;
            }

            if (!skipFireEvent)
                fireListTextClicked(idFeed, true, ((FolderSubscribtionItem) group).idFolder);
        }
    });

    viewHolder.listItemLayout.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {

            long idFeed = group.id_database;

            if (group instanceof ConcreteFeedItem) {
                fireListTextLongClicked(idFeed, false, (long) ITEMS_WITHOUT_FOLDER.getValue());
            } else {
                fireListTextLongClicked(idFeed, true, ((FolderSubscribtionItem) group).idFolder);
            }
            return true; //consume event
        }
    });

    viewHolder.txt_UnreadCount.setText("");
    boolean skipGetUnread = false;
    if (group.idFolder != null && group.idFolder == ITEMS_WITHOUT_FOLDER.getValue()) {
        String unreadCount = unreadCountFeeds.get((int) group.id_database);
        if (unreadCount != null) {
            viewHolder.txt_UnreadCount.setText(unreadCount);
        }

        skipGetUnread = true;
    }

    if (!skipGetUnread) {
        String unreadCount = unreadCountFolders.get((int) group.id_database);
        if (unreadCount != null)
            viewHolder.txt_UnreadCount.setText(unreadCount);
    }

    int rotation = 0;
    int contentDescriptionId = R.string.content_desc_none;

    if (group.idFolder != null) {
        viewHolder.imgView.setVisibility(View.GONE);
        if (group.idFolder == ITEMS_WITHOUT_FOLDER.getValue()) {
            ConcreteFeedItem concreteFeedItem = ((ConcreteFeedItem) group);
            favIconHandler.loadFavIconForFeed(concreteFeedItem.favIcon, viewHolder.faviconView);
        }
    } else {
        if (group.id_database == ALL_STARRED_ITEMS.getValue()) {
            viewHolder.imgView.setVisibility(View.GONE);
            viewHolder.faviconView.setVisibility(View.VISIBLE);
            rotation = 0;
            viewHolder.faviconView.setImageResource(getBtn_rating_star_off_normal_holo_light());
        } else if (getChildrenCount(groupPosition) == 0) {
            viewHolder.imgView.setVisibility(View.GONE);
            viewHolder.faviconView.setVisibility(View.INVISIBLE);
        } else {
            viewHolder.imgView.setVisibility(View.VISIBLE);
            viewHolder.faviconView.setVisibility(View.INVISIBLE);
            viewHolder.imgView.setImageResource(R.drawable.ic_action_expand_less);

            if (isExpanded) {
                rotation = 180;
                contentDescriptionId = R.string.content_desc_collapse;
            } else {
                if (ViewUtils.isLayoutRtl(listView)) {
                    rotation = -90; // mirror for rtl layout
                } else {
                    rotation = 90;
                }
                contentDescriptionId = R.string.content_desc_expand;
            }

            viewHolder.imgView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (isExpanded)
                        ((ExpandableListView) listView).collapseGroup(groupPosition);
                    else
                        ((ExpandableListView) listView).expandGroup(groupPosition);
                }
            });
        }
    }

    viewHolder.imgView.setRotation(rotation);
    viewHolder.imgView.setContentDescription(viewHolder.imgView.getContext().getString(contentDescriptionId));

    return convertView;
}

From source file:uk.org.downiesoft.slideshow.BrowserAdapter.java

/**
 * {@inheritDoc}//from w w  w.  j  a va 2  s .  com
 */
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    LinearLayout browserItemView;
    Holder holder;
    if (convertView == null) {
        browserItemView = new LinearLayout(mContext);
        mInflater.inflate(mResource, browserItemView, true);
        holder = new Holder();
        holder.image = (ImageView) browserItemView.findViewById(R.id.rowImage);
        holder.name = (TextView) browserItemView.findViewById(R.id.rowFilename);
        holder.count = (TextView) browserItemView.findViewById(R.id.rowCount);
        browserItemView.setTag(holder);
    } else {
        browserItemView = (LinearLayout) convertView;
        holder = (Holder) browserItemView.getTag();
    }

    final ImageView imageView = holder.image;

    final TextView textView = holder.name;
    final TextView countView = holder.count;

    ZFile item = getItem(position);
    String name = item.getName();
    if (item.isDirectory() && item.getSubPath().length() == 0) {
        if (mThumbBitmaps.get(position) != null)
            imageView.setImageBitmap(mThumbBitmaps.get(position));
        else
            imageView.setImageResource(R.drawable.folder);
        textView.setText(name.substring(0, name.length()));
        if (mCountsCache.get(position) != null) {
            countView.setText(String.format("%d", mCountsCache.get(position)));
        } else {
            countView.setText("\u2026");
        }
    } else if (item.getSubPath().equals(mContext.getString(R.string.text_images_placeholder))) {
        imageView.setImageBitmap(mThumbBitmaps.get(position));
        textView.setText(name.substring(0, name.length()));
        if (mCountsCache.get(position) != null) {
            countView.setText(String.format("%d", mCountsCache.get(position)));
        } else {
            countView.setText("");
        }
    } else {
        if (mThumbBitmaps.get(position) != null)
            imageView.setImageBitmap(mThumbBitmaps.get(position));
        else
            imageView.setImageResource(R.drawable.ic_launcher);
        if (mCountsCache.get(position) != null) {
            countView.setText(String.format("%d", mCountsCache.get(position)));
        } else {
            countView.setText("\u2026");
        }
        textView.setText(name);
    }
    return browserItemView;
}