Java Code Examples for android.widget.LinearLayout.setTag()

The following are Jave code examples for showing how to use setTag() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Symphony   File: SongAdapter.java   View Source Code Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if( convertView == null ){
        //We must create a View:
        convertView = songInf.inflate(R.layout.song, parent, false);
    }        //map to song layout
    LinearLayout songLay = (LinearLayout) convertView;
    //get title and artist views
    TextView songView = (TextView) songLay.findViewById(R.id.song_title);
    TextView artistView = (TextView) songLay.findViewById(R.id.song_artist);
    //get song using position
    Song currSong = songs.get(position);
    //get title and artist strings
    songView.setText(currSong.getTitle());
    artistView.setText(currSong.getArtist());
    //set position as tag
    songLay.setTag(position);
    return songLay;
}
 
Example 2
Project: Closet   File: FilterBarLayout.java   View Source Code Vote up 6 votes
private void init(Context context) {
    mContainIndicatorAndFooterLayout = new RelativeLayout(getContext());
    mOriginContainIndicatorAndFooterLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    mContainIndicatorAndFooterLayout.setLayoutParams(mOriginContainIndicatorAndFooterLayoutParams);

    mIndicatorLayout = new LinearLayout(context);
    //用来标记子控件,以便重排子控件在父容器顺序
    mIndicatorLayout.setTag(BODY_LAYOUT_TAG);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mFilterBarHeight);
    mIndicatorLayout.setLayoutParams(layoutParams);
    mIndicatorLayout.setBackgroundColor(Color.WHITE);
    mIndicatorLayout.setGravity(Gravity.CENTER_VERTICAL);
    mIndicatorLayout.setOrientation(LinearLayout.HORIZONTAL);

    mContainIndicatorAndFooterLayout.addView(mIndicatorLayout);
    addView(mContainIndicatorAndFooterLayout);

    int size = mIndicatorUnitList.size();
    for (int i = 0; i < size; i++) {
        addIndicatorUnit(context, i);
        if (i < size - 1) {
            addFilterBarLine(context);
        }
    }
}
 
Example 3
Project: Orin   File: BreadCrumbLayout.java   View Source Code Vote up 6 votes
public void addCrumb(@NonNull Crumb crumb, boolean refreshLayout) {
    LinearLayout view = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.bread_crumb, this, false);
    view.setTag(mCrumbs.size());
    view.setOnClickListener(this);

    ImageView iv = (ImageView) view.getChildAt(1);
    if (Build.VERSION.SDK_INT >= 19 && iv.getDrawable() != null) {
        iv.getDrawable().setAutoMirrored(true);
    }
    iv.setVisibility(View.GONE);

    mChildFrame.addView(view, new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mCrumbs.add(crumb);
    if (refreshLayout) {
        mActive = mCrumbs.size() - 1;
        requestLayout();
    }
    invalidateActivatedAll();
}
 
Example 4
Project: androidgithub   File: LinearBreadcrumbView.java   View Source Code Vote up 6 votes
public void addCrumb(@NonNull Crumb crumb, boolean refreshLayout) {
    LinearLayout view = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.layout_bread_crumb, this, false);
    view.setTag(mCrumbs.size());
    view.setOnClickListener(this);

    ImageView iv = (ImageView) view.getChildAt(1);
    Drawable arrow = getResources().getDrawable(R.mipmap.ic_right_arrow);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (arrow != null) {
            arrow.setAutoMirrored(true);
        }
    }
    iv.setImageDrawable(arrow);
    iv.setVisibility(View.GONE);

    mChildFrame.addView(view, new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mCrumbs.add(crumb);
    if (refreshLayout) {
        mActive = mCrumbs.size() - 1;
        requestLayout();
    }
    invalidateActivatedAll();
}
 
Example 5
Project: ePills   File: AddPillSetTime.java   View Source Code Vote up 6 votes
@Override
public void onRestoreInstanceState(Bundle state) {
    boolean[] weekstate = state.getBooleanArray(STATE_WEEK);
    for (int i = 0; i < weekstate.length; i++) {
        LinearLayout day = getDayLayout(i);
        day.setTag(weekstate[i]);
    }

    if (singleSelected) {
        disableDays();
    } else {
        enableDays();
    }

    super.onRestoreInstanceState(state);
}
 
Example 6
Project: RetroMusicPlayer   File: BreadCrumbLayout.java   View Source Code Vote up 6 votes
public void addCrumb(@NonNull Crumb crumb, boolean refreshLayout) {
    LinearLayout view = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.bread_crumb, this, false);
    view.setTag(mCrumbs.size());
    view.setOnClickListener(this);

    ImageView iv = (ImageView) view.getChildAt(1);
    if (Build.VERSION.SDK_INT >= 19 && iv.getDrawable() != null) {
        iv.getDrawable().setAutoMirrored(true);
    }
    iv.setVisibility(View.GONE);

    mChildFrame.addView(view, new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mCrumbs.add(crumb);
    if (refreshLayout) {
        mActive = mCrumbs.size() - 1;
        requestLayout();
    }
    invalidateActivatedAll();
}
 
Example 7
Project: RLibrary   File: SwipeMenuView.java   View Source Code Vote up 6 votes
private void addItem(SwipeMenuItem item, int index) {
    LayoutParams params = new LayoutParams(item.getWidth(), item.getHeight());
    params.weight = item.getWeight();
    LinearLayout parent = new LinearLayout(getContext());
    parent.setId(index);
    parent.setGravity(Gravity.CENTER);
    parent.setOrientation(VERTICAL);
    parent.setLayoutParams(params);
    ResCompat.setBackground(parent, item.getBackground());
    parent.setTag(item);
    parent.setOnClickListener(mMenuClickListener);
    addView(parent);

    if (item.getImage() != null)
        parent.addView(createIcon(item));

    if (!TextUtils.isEmpty(item.getText()))
        parent.addView(createTitle(item));
}
 
Example 8
Project: android-MaterialPillsBox   File: MaterialPillsBox.java   View Source Code Vote up 5 votes
public void notifyDataSetChanged() {
    removeAllViews();
    for (int i = 0; i < objectList.size(); i++) {
        if (i < maxPills) {
            LinearLayout linear = setupPillChildView(
                    ((PillEntity) objectList.get(i)).getMessage(),
                    ((PillEntity) objectList.get(i)).isPressed(),
                    ((PillEntity) objectList.get(i)).getImgResource()
            );
            addView(linear);
            linear.setTag(i);
        }
    }
}
 
Example 9
Project: qmui   File: QMUIBottomSheet.java   View Source Code Vote up 5 votes
public BottomGridSheetBuilder addItem(int imageRes, CharSequence text, Object tag, @Style int style, int subscriptRes) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    // 给机会让用的人自定义ItemView
    LinearLayout itemView = (LinearLayout) inflater.inflate(R.layout.qmui_bottom_sheet_grid_item, null, false);
    // 字体加粗
    TextView titleTV = (TextView) itemView.findViewById(R.id.grid_item_title);
    if(mItemTextTypeFace != null){
        titleTV.setTypeface(mItemTextTypeFace);
    }
    titleTV.setText(text);

    itemView.setTag(tag);
    itemView.setOnClickListener(this);
    AppCompatImageView imageView = (AppCompatImageView) itemView.findViewById(R.id.grid_item_image);
    imageView.setImageResource(imageRes);

    if (subscriptRes != 0) {
        ViewStub stub = (ViewStub) itemView.findViewById(R.id.grid_item_subscript);
        View inflated = stub.inflate();
        ((ImageView) inflated).setImageResource(subscriptRes);
    }

    switch (style) {
        case FIRST_LINE:
            mFirstLineViews.append(mFirstLineViews.size(), itemView);
            break;
        case SECOND_LINE:
            mSecondLineViews.append(mSecondLineViews.size(), itemView);
            break;
    }
    return this;
}
 
Example 10
Project: android_viewtracker   File: UltraPagerAdapter.java   View Source Code Vote up 5 votes
@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);
        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;
        }
        linearLayout.setTag(TrackerConstants.VIEW_TAG_UNIQUE_NAME, "home_banner_item_" + position);
        Map<String, String> map = new HashMap();
        map.put("content", textView.getText().toString());
        linearLayout.setTag(TrackerConstants.VIEW_TAG_PARAM, map);
        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;
    }
 
Example 11
Project: PicShow-zhaipin   File: FixedIndicatorView.java   View Source Code Vote up 5 votes
@Override
public void onChange() {
    if (!inRun.isFinished()) {
        inRun.stop();
    }
    int count = getTabCountInLayout();
    int newCount = mAdapter.getCount();
    views.clear();
    for (int i = 0; i < count && i < newCount; i++) {
        views.add((ViewGroup) getItemOutView(i));
    }
    removeAllViews();
    int size = views.size();
    for (int i = 0; i < newCount; i++) {
        LinearLayout result = new LinearLayout(getContext());
        View view;
        if (i < size) {
            View temp = views.get(i).getChildAt(0);
            views.get(i).removeView(temp);
            view = mAdapter.getView(i, temp, result);
        } else {
            view = mAdapter.getView(i, null, result);
        }
        if (onTransitionListener != null) {
            onTransitionListener.onTransition(view, i, i == mSelectedTabIndex ? 1 : 0);
        }
        result.addView(view);
        result.setOnClickListener(onClickListener);
        result.setTag(i);
        addView(result, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    }
    if (centerView != null) {
        setCenterView(centerView, centerViewLayoutParams);
    }
    mPreSelectedTabIndex = -1;
    setCurrentItem(mSelectedTabIndex, false);
    measureTabs();
}
 
Example 12
Project: microMathematics   File: FormulaTermLoop.java   View Source Code Vote up 5 votes
private LinearLayout getLayoutWithTag(final String tag)
{
    LinearLayout retValue = (LinearLayout) layout.findViewWithTag(tag);
    if (retValue != null)
    {
        retValue.setTag(null);
    }
    return retValue;
}
 
Example 13
Project: ePills   File: AddPillSetTime.java   View Source Code Vote up 5 votes
/**
 * Selects the Day on position 'index'.
 * @param index
 * @param dayLayout
 * @param check: True if checkDays() should be called.
 */
private void activateDay(int index, LinearLayout dayLayout, boolean check) {
    weekdaysSelection[index] = true;

    dayLayout.setTag(true);
    Drawable bg = ContextCompat.getDrawable(getBaseContext(), R.drawable.circle_step);
    int colorPrimary = ContextCompat.getColor(getBaseContext(), R.color.accent);
    bg.setColorFilter(new PorterDuffColorFilter(colorPrimary, PorterDuff.Mode.SRC_IN));
    dayLayout.setBackground(bg);
    TextView day = (TextView) dayLayout.findViewById(R.id.day);
    day.setTextColor(ContextCompat.getColor(getBaseContext(),R.color.md_white_1000));
    if(check) {
        checkDays();
    }
}
 
Example 14
Project: ePills   File: AddPillSetTime.java   View Source Code Vote up 5 votes
/**
 * Deselects the day on position 'index'.
 * @param index
 * @param dayLayout
 * @param check: True if method checkDays() should be called.
 */
private void deactivateDay(int index, LinearLayout dayLayout, boolean check) {
    weekdaysSelection[index] = false;

    dayLayout.setTag(false);

    dayLayout.setBackgroundResource(0);

    TextView textView = dayLayout.findViewById(R.id.day);
    textView.setTextColor(ContextCompat.getColor(getBaseContext(),R.color.primary));

    if (check) {
        checkDays();
    }
}
 
Example 15
Project: thingplug-sdk-android   File: SensorListActivity.java   View Source Code Vote up 5 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rowView = inflater.inflate(R.layout.sensor_list_item, parent, false);
    LinearLayout itemLayout = (LinearLayout) rowView.findViewById(R.id.item_layout);
    ImageView itemImageView = (ImageView) rowView.findViewById(R.id.item_image);
    TextView itemNameView = (TextView) rowView.findViewById(R.id.item_name);
    TextView itemStatus = (TextView) rowView.findViewById(R.id.item_status);
    ToggleButton itemEnable = (ToggleButton) rowView.findViewById(R.id.item_enable);
    ToggleButton itemActivate = (ToggleButton) rowView.findViewById(R.id.item_activate);
    Button itemActuatorRun = (Button) rowView.findViewById(R.id.item_actuator_run);
    itemActuatorRun.setVisibility(View.GONE);

    final SensorInfo sensorInfo = sensorInfos.get(position);
    itemImageView.setImageResource(sensorInfo.getType().getImage());
    itemNameView.setText(sensorInfo.getType().getNickname());
    itemEnable.setChecked(sensorInfo.isEnable());
    if (sensorInfo.getType().getCategory() == SensorType.Category.ACTUATOR) {
        itemStatus.setVisibility(View.GONE);
        itemActivate.setVisibility(View.GONE);
    }
    else {
        itemActivate.setEnabled(false);
        itemStatus.setText(sensorInfo.toString());
        itemActivate.setChecked(sensorInfo.isActivated());
    }

    // sensor item click
    itemLayout.setTag(sensorInfo);
    itemLayout.setOnClickListener(listItemClickListener);

    // sensor enable button click
    itemEnable.setTag(sensorInfo);
    itemEnable.setOnClickListener(enableClickListener);

    return rowView;
}
 
Example 16
Project: Huochexing12306   File: FollowList.java   View Source Code Vote up 4 votes
public View getView(int position, View convertView, ViewGroup parent) {
	FollowListItem item = null;
	if (convertView == null) {
		LinearLayout llItem = new LinearLayout(parent.getContext());
		item = new FollowListItem();
		llItem.setTag(item);
		convertView = llItem;

		item.aivIcon = new AsyncImageView(getContext());
		int dp_52 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 52);
		int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(parent.getContext(), 10);
		int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(parent.getContext(), 5);
		LinearLayout.LayoutParams lpIcon = new LinearLayout.LayoutParams(dp_52, dp_52);
		lpIcon.gravity = Gravity.CENTER_VERTICAL;
		lpIcon.setMargins(dp_10, dp_5, dp_10, dp_5);
		item.aivIcon.setLayoutParams(lpIcon);
		llItem.addView(item.aivIcon);

		LinearLayout llText = new LinearLayout(parent.getContext());
		llText.setPadding(0, dp_10, dp_10, dp_10);
		llText.setOrientation(LinearLayout.VERTICAL);
		LinearLayout.LayoutParams lpText = new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lpText.gravity = Gravity.CENTER_VERTICAL;
		lpText.weight = 1;
		llText.setLayoutParams(lpText);
		llItem.addView(llText);

		item.tvName = new TextView(parent.getContext());
		item.tvName.setTextColor(0xff000000);
		item.tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
		item.tvName.setSingleLine();
		llText.addView(item.tvName);

		item.tvSign = new TextView(parent.getContext());
		item.tvSign.setTextColor(0x7f000000);
		item.tvSign.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
		item.tvSign.setSingleLine();
		llText.addView(item.tvSign);

		item.ivCheck = new ImageView(parent.getContext());
		item.ivCheck.setPadding(0, 0, dp_10, 0);
		LinearLayout.LayoutParams lpCheck = new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lpCheck.gravity = Gravity.CENTER_VERTICAL;
		item.ivCheck.setLayoutParams(lpCheck);
		llItem.addView(item.ivCheck);
	} else {
		item = (FollowListItem) convertView.getTag();
	}

	Following following = getItem(position);
	item.tvName.setText(following.screeName);
	item.tvSign.setText(following.description);
	item.ivCheck.setImageBitmap(following.checked ? bmChd : bmUnch);
	if (isFling()) {
		Bitmap bm = BitmapProcessor.getBitmapFromCache(following.icon);
		if (bm != null && !bm.isRecycled()) {
			item.aivIcon.setImageBitmap(bm);
		} else {
			item.aivIcon.execute(null, AsyncImageView.DEFAULT_TRANSPARENT);
		}
	} else {
		item.aivIcon.execute(following.icon);
	}

	if (position == getCount() - 1) {
		next();
	}
	return convertView;
}
 
Example 17
Project: microbit   File: ProjectAdapter.java   View Source Code Vote up 4 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    Project project = mProjects.get(position);
    if(convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(MBApp.getApp());
        convertView = inflater.inflate(R.layout.project_items, null);
    }

    Button appNameButton = (Button) convertView.findViewById(R.id.appNameButton);
    appNameButton.setTypeface(MBApp.getApp().getRobotoTypeface());

    ExtendedEditText appNameEdit = (ExtendedEditText) convertView.findViewById(R.id.appNameEdit);
    appNameEdit.setTypeface(MBApp.getApp().getRobotoTypeface());

    LinearLayout actionBarLayout = (LinearLayout) convertView.findViewById(R.id.actionBarForProgram);
    if(actionBarLayout != null) {
        if(project.actionBarExpanded) {
            actionBarLayout.setVisibility(View.VISIBLE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_down), null);
        } else {
            actionBarLayout.setVisibility(View.GONE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_left), null);
        }
    }

    appNameButton.setText(project.name);
    appNameButton.setTag(R.id.positionId, position);
    appNameButton.setTag(R.id.textEdit, appNameEdit);
    appNameButton.setOnClickListener(appNameClickListener);
    appNameButton.setOnLongClickListener(appNameLongClickListener);

    appNameEdit.setTag(R.id.positionId, position);
    appNameEdit.setTag(R.id.editbutton, appNameButton);
    appNameEdit.setOnEditorActionListener(editorOnActionListener);
    appNameEdit.setFilters(new InputFilter[]{renameFilter});

    if(project.inEditMode) {
        appNameEdit.setVisibility(View.VISIBLE);

        appNameEdit.setText(project.name);
        appNameEdit.setSelection(project.name.length());
        appNameEdit.requestFocus();
        appNameButton.setVisibility(View.INVISIBLE);

    } else {
        appNameEdit.setVisibility(View.INVISIBLE);
        appNameButton.setVisibility(View.VISIBLE);
        //dismissKeyBoard(appNameEdit, false);
    }

    //appNameEdit.setOnClickListener(appNameClickListener);

    TextView flashBtnText = (TextView) convertView.findViewById(R.id.project_item_text);
    flashBtnText.setTypeface(MBApp.getApp().getRobotoTypeface());
    LinearLayout sendBtnLayout = (LinearLayout) convertView.findViewById(R.id.sendBtn);
    sendBtnLayout.setTag(position);
    sendBtnLayout.setOnClickListener(sendBtnClickListener);

    ImageButton deleteBtn = (ImageButton) convertView.findViewById(R.id.deleteBtn);
    deleteBtn.setTag(position);
    deleteBtn.setOnClickListener(deleteBtnClickListener);
    deleteBtn.setEnabled(true);


    Drawable myIcon;
    if(project.runStatus) {
        flashBtnText.setText("");
        myIcon = convertView.getResources().getDrawable(R.drawable.green_btn);
    } else {
        flashBtnText.setText(R.string.flash);
        myIcon = convertView.getResources().getDrawable(R.drawable.blue_btn);
    }
    sendBtnLayout.setBackground(myIcon);

    sendBtnLayout.setClickable(true);
    return convertView;
}
 
Example 18
Project: thingplug-sdk-android   File: SensorListActivity.java   View Source Code Vote up 4 votes
@Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View rowView = inflater.inflate(R.layout.sensor_list_item, parent, false);
            LinearLayout itemLayout = (LinearLayout) rowView.findViewById(R.id.item_layout);
            ImageView itemImageView = (ImageView) rowView.findViewById(R.id.item_image);
            TextView itemNameView = (TextView) rowView.findViewById(R.id.item_name);
            TextView itemStatus = (TextView) rowView.findViewById(R.id.item_status);
            ToggleButton itemEnable = (ToggleButton) rowView.findViewById(R.id.item_enable);
            ToggleButton itemActivate = (ToggleButton) rowView.findViewById(R.id.item_activate);
            Button itemActuatorRun = (Button) rowView.findViewById(R.id.item_actuator_run);
            itemEnable.setVisibility(View.GONE);

            SensorInfo sensorInfo = sensorInfos.get(position);
            itemImageView.setImageResource(sensorInfo.getType().getImage());
            itemNameView.setText(sensorInfo.getType().getNickname());
//            itemEnable.setChecked(sensorInfo.isEnable());
            if (sensorInfo.getType().getCategory() == SensorType.Category.ACTUATOR) {
                itemStatus.setVisibility(View.GONE);
                itemActivate.setVisibility(View.GONE);
                itemActuatorRun.setEnabled(sensorInfo.isActivated() && !sensorInfo.isSuspend());
            }
            else {
                itemActuatorRun.setVisibility(View.GONE);
                itemStatus.setText(sensorInfo.toString());
                itemActivate.setChecked(sensorInfo.isActivated());
                itemActivate.setEnabled(!sensorInfo.isSuspend());
            }

            // sensor item click
            itemLayout.setTag(sensorInfo);
            itemLayout.setOnClickListener(listItemClickListener);

            // sensor activation button click
            itemActivate.setTag(sensorInfo);
            itemActivate.setOnClickListener(activateClickListener);

            // actuator run button click
            itemActuatorRun.setTag(sensorInfo);
            itemActuatorRun.setOnClickListener(actuatorRunClickListener);

            return rowView;
        }
 
Example 19
Project: thingplug-app-android   File: SensorListActivity.java   View Source Code Vote up 4 votes
@Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View rowView = inflater.inflate(R.layout.sensor_list_item, parent, false);
            LinearLayout itemLayout = (LinearLayout) rowView.findViewById(R.id.item_layout);
            ImageView itemImageView = (ImageView) rowView.findViewById(R.id.item_image);
            TextView itemNameView = (TextView) rowView.findViewById(R.id.item_name);
            TextView itemStatus = (TextView) rowView.findViewById(R.id.item_status);
            ToggleButton itemEnable = (ToggleButton) rowView.findViewById(R.id.item_enable);
            ToggleButton itemActivate = (ToggleButton) rowView.findViewById(R.id.item_activate);
            Button itemActuatorRun = (Button) rowView.findViewById(R.id.item_actuator_run);
            itemEnable.setVisibility(View.GONE);

            SensorInfo sensorInfo = sensorInfos.get(position);
            itemImageView.setImageResource(sensorInfo.getType().getImage());
            itemNameView.setText(sensorInfo.getType().getNickname());
//            itemEnable.setChecked(sensorInfo.isEnable());
            if (sensorInfo.getType().getCategory() == SensorType.Category.ACTUATOR) {
                itemStatus.setVisibility(View.GONE);
                itemActivate.setVisibility(View.GONE);
                itemActuatorRun.setEnabled(!sensorInfo.isControlling()); // && !sensorInfo.isSuspend());
            }
            else {
                itemActuatorRun.setVisibility(View.GONE);
                itemStatus.setText(sensorInfo.toString());
                itemActivate.setChecked(sensorInfo.isActivated());
                itemActivate.setEnabled(!sensorInfo.isControlling()); // !sensorInfo.isSuspend());
            }

            // sensor item click
            itemLayout.setTag(sensorInfo);
            itemLayout.setOnClickListener(listItemClickListener);

            // sensor activation button click
            itemActivate.setTag(sensorInfo);
            itemActivate.setOnClickListener(activateClickListener);

            // actuator run button click
            itemActuatorRun.setTag(sensorInfo);
            itemActuatorRun.setOnClickListener(actuatorRunClickListener);

            return rowView;
        }