当前位置: 首页>>代码示例>>Java>>正文


Java Button.setTag方法代码示例

本文整理汇总了Java中android.widget.Button.setTag方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setTag方法的具体用法?Java Button.setTag怎么用?Java Button.setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.Button的用法示例。


在下文中一共展示了Button.setTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getButton

import android.widget.Button; //导入方法依赖的package包/类
private Button getButton(String text, int position) {

        // 动态生成选择按钮
        final Button button = new Button(mContext);
        button.setText(text);
        button.setTag(position);
        button.setTextColor(mBuilder.getItemTextColor());
        button.setTextSize(mBuilder.getItemTextSize());
        button.setLayoutParams(new LinearLayout.LayoutParams(AbsListView.LayoutParams
                .MATCH_PARENT, mBuilder.getItemHeight()));
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {

                if (mBuilder.getOnItemListener() != null) {

                    selectPosition = Integer.parseInt(button.getTag().toString());
                    mBuilder.getOnItemListener().onItemClick(button, selectPosition);

                }
            }
        });

        return button;
    }
 
开发者ID:wp521,项目名称:MyFire,代码行数:27,代码来源:NormalSelectionDialog.java

示例2: addDisplayUnitButton

import android.widget.Button; //导入方法依赖的package包/类
/**
 * 添加展示按钮
 * @param unitModel
 * @throws ClassNotFoundException
 */
private void addDisplayUnitButton(final DUnitBaseModel unitModel) throws ClassNotFoundException {
	Button button = (Button) getLayoutInflater().inflate(R.layout.btn_item_simplelist_dunit,mMainLinearLayout,false);
	button.setText(unitModel.getName());
	//禁止大写
	button.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			switch (unitModel.getModelType()){
				case MODEL_TYPE_UNIT:
					doUnit((DUnitModel) unitModel,v);
					break;
				case MODEL_TYPE_GROUP:
					startNextPage(unitModel);
					break;
			}
		}
	});
	mMainLinearLayout.addView(button);
	if (unitModel.getModelType() == ModelType.MODEL_TYPE_UNIT){
		View messageView = getLayoutInflater().inflate(R.layout.message_simplelist_dunit,mMainLinearLayout,false);
		mMainLinearLayout.addView(messageView);
		button.setTag(messageView);
	}
}
 
开发者ID:tik5213,项目名称:DUnit,代码行数:30,代码来源:DUnitSimpleListActivity.java

示例3: initViews

import android.widget.Button; //导入方法依赖的package包/类
private void initViews() {
	TextView tvInfo1 = (TextView)findViewById(R.id.info);
	memberLayout = (LinearLayout)findViewById(R.id.about_memberLayout);
	teamLogo = (ImageView)findViewById(R.id.about_teamLogo);
	btnEmail = (Button)findViewById(R.id.email);
	btnEmail.setOnClickListener(this);
	btnQQ = (Button)findViewById(R.id.about_btnQQ);
	btnQQ.setOnClickListener(this);
	llytSinaWeibo = (LinearLayout)findViewById(R.id.about_llytSinaWeiBo);
	llytSinaWeibo.setOnClickListener(this);
	tvSinaWeibo = (TextView)findViewById(R.id.about_sinaWeiBo);
	
	String strInfo1 = "应用版本:V"+MyUtils.getVersionName(this);
	tvInfo1.setText(Html.fromHtml(strInfo1));
	String strEmail = "[email protected]";
	btnEmail.setText(Html.fromHtml("<u>联系邮箱: "+strEmail+"</u>"));
	btnEmail.setTag(strEmail);
	btnQQ.setText(Html.fromHtml("<u>" + strQQ + "</u>"));
	tvSinaWeibo.setText(Html.fromHtml("<u>@"+strSinaWeibo+"</u>"));
	teamLogo.setOnLongClickListener(new View.OnLongClickListener() {
		@Override
		public boolean onLongClick(View v) {
			memberLayout.setVisibility(memberLayout.isShown() ? View.GONE : View.VISIBLE);
			return false;
		}
	});
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:28,代码来源:AboutAty.java

示例4: showBtn

import android.widget.Button; //导入方法依赖的package包/类
void showBtn(){
    String strs[]=new String[]{"Calc","Jump"};
    int x=200,y=100,w=100,h=100;
    for(int i=0;i<strs.length;i++) {
        Button button = new Button(cxt);
        button.setText(strs[i]);
        button.setTag(strs[i]);
        button.setBackgroundColor(Color.RED);
        WindowManager.LayoutParams p = createLayoutParams(x*i+50, y, w, h);
        initEvents(button);
        map.put(button, p);
        windowManager.addView(button, p);
    }
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:15,代码来源:FloatView.java

示例5: getButton

import android.widget.Button; //导入方法依赖的package包/类
private Button getButton(String text, int position) {

        // 动态生成选择按钮
        final Button button = new Button(mContext);
        button.setText(text);
        button.setTag(position);
        button.setTextColor(mBuilder.getItemTextColor());
        button.setTextSize(mBuilder.getItemTextSize());
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams
                .MATCH_PARENT, mBuilder.getItemHeight());
        button.setLayoutParams(lp);
        button.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
        button.setPadding(UiUtils.dp2px(mContext,10),0,UiUtils.dp2px(mContext,10),0);
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {

                if (mBuilder.getOnItemListener() != null) {

                    selectPosition = Integer.parseInt(button.getTag().toString());
                    mBuilder.getOnItemListener().onItemClick(button, selectPosition);

                }
            }
        });

        return button;
    }
 
开发者ID:wp521,项目名称:MyFire,代码行数:30,代码来源:MDSelectionDialog.java

示例6: updateButtonVisibilities

import android.widget.Button; //导入方法依赖的package包/类
private void updateButtonVisibilities() {
    debugRootView.removeAllViews();

    retryButton.setVisibility(playerNeedsSource ? View.VISIBLE : View.GONE);
    debugRootView.addView(retryButton);

    if (player == null) {
        return;
    }

    MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
    if (mappedTrackInfo == null) {
        return;
    }

    for (int i = 0; i < mappedTrackInfo.length; i++) {
        TrackGroupArray trackGroups = mappedTrackInfo.getTrackGroups(i);
        if (trackGroups.length != 0) {
            Button button = new Button(this);
            int label;
            switch (player.getRendererType(i)) {
                case C.TRACK_TYPE_AUDIO:
                    label = R.string.audio;
                    break;
                case C.TRACK_TYPE_VIDEO:
                    label = R.string.video;
                    break;
                case C.TRACK_TYPE_TEXT:
                    label = R.string.text;
                    break;
                default:
                    continue;
            }
            button.setText(label);
            button.setTag(i);
            button.setOnClickListener(this);
            debugRootView.addView(button, debugRootView.getChildCount() - 1);
        }
    }
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:41,代码来源:PlayerActivity.java

示例7: populateDevices

import android.widget.Button; //导入方法依赖的package包/类
/**
 *
 */
private void populateDevices() {
    final LinearLayout mainLinearLayout = findViewById(R.id.mainLinearLayout);
    final CardView addPictureCard = findViewById(R.id.addPictureCard);

    for (final DeviceDAO deviceDAO : story.getDevices()) {
        final View previousDeviceView = mainLinearLayout.findViewById(deviceDAO.getId());
        if (previousDeviceView != null) {
            mainLinearLayout.removeView(previousDeviceView);
        }
        final View deviceView = getLayoutInflater().inflate(R.layout.story_activity_card_device, mainLinearLayout, false);

        // Pass args to buttons in order to perfom some actions on the device
        Button deleteDevice = deviceView.findViewById(R.id.delete_device);
        deleteDevice.setTag(R.id.cardDevice, deviceDAO);

        Button configureDevice = deviceView.findViewById(R.id.configure_device);
        configureDevice.setTag(R.id.cardDevice, deviceDAO);

        deviceView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                showRemoveDeviceDialog(deviceDAO);
                return true;
            }
        });

        // Hide the text if the device has no NetBios name (should be improved by the way)
        TextView name = deviceView.findViewById(R.id.name);
        if (deviceDAO.getName() == null) {
            name.setVisibility(View.GONE);
        } else {
            name.setText(deviceDAO.getName());
        }

        TextView ip = deviceView.findViewById(R.id.ip);
        ip.setText(deviceDAO.getIP());
        TextView vendor = deviceView.findViewById(R.id.vendor);
        vendor.setText(deviceDAO.getVendor());

        // Show the lock icon if device is password protected
        if (deviceDAO.isProtected()) {
            ImageView lockIcon = deviceView.findViewById(R.id.lockIcon);
            lockIcon.setVisibility(View.VISIBLE);
        }

        deviceView.setId(deviceDAO.getId());
        mainLinearLayout.addView(deviceView, mainLinearLayout.indexOfChild(addPictureCard));
    }
}
 
开发者ID:MBach,项目名称:home-automation,代码行数:53,代码来源:StoryActivity.java

示例8: makeList

import android.widget.Button; //导入方法依赖的package包/类
public void makeList(){

        if(remarks.size() > 0){
            tv_msg.setVisibility(View.GONE);
        }else{
            tv_msg.setVisibility(View.VISIBLE);
            setFadeInAnimation(tv_msg);
        }

        li_symptom.removeAllViews();
        for(int i=0; i<remarks.size(); i++){
            PatientRemark patientRemark = remarks.get(i);

            View v = getLayoutInflater().inflate(R.layout.patient_remark_list_custom_item, null, false);
            TextView tv_title = (TextView)v.findViewById(R.id.tv_title);
            Button btn_select = (Button)v.findViewById(R.id.btn_select);

            tv_title.setText(patientRemark.getDescription());
            btn_select.setBackgroundResource(R.drawable.two_btn_active_right_radius_red);
            btn_select.setText(R.string.delete_srt);
            btn_select.setTag(i);
            btn_select.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    int tag = (int)view.getTag();
                    remarks.remove(tag);
                    makeList();
                }
            });

            li_symptom.addView(v);

        }

    }
 
开发者ID:pooi,项目名称:Nearby,代码行数:36,代码来源:RecordRemarkActivity.java

示例9: buildMedicineList

import android.widget.Button; //导入方法依赖的package包/类
private void buildMedicineList(){

        li_medicineList.removeAllViews();

        for(final PatientMedicineDetail detail : list){

            View v = getLayoutInflater().inflate(R.layout.add_medicine_list_custom_item, null, false);

            TextView tv_name = (TextView)v.findViewById(R.id.tv_name);
            TextView tv_code = (TextView)v.findViewById(R.id.tv_code);
            TextView tv_info = (TextView)v.findViewById(R.id.tv_info);
            TextView tv_time = (TextView)v.findViewById(R.id.tv_time);
            Button deleteBtn = (Button)v.findViewById(R.id.btn_delete);
            deleteBtn.setTag((PatientMedicineDetail)detail);

            Medicine medicine = detail.getMedicine();
            tv_name.setText(medicine.getNameSrt());
            tv_code.setText(medicine.getCode());
            tv_info.setText(detail.getSd() + "/" + detail.getNdd() + "/" + detail.getTdd() + "/" + detail.getDescription());
            tv_time.setText(detail.getTime());

            deleteBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    deleteDetail(detail);
                }
            });

            li_medicineList.addView(v);

        }

        checkSaveBtn();

    }
 
开发者ID:pooi,项目名称:Nearby,代码行数:36,代码来源:AddPatientMedicineActivity.java

示例10: setupMyRequests

import android.widget.Button; //导入方法依赖的package包/类
private void setupMyRequests() {
    Button btn1 = getDialog().findViewById(R.id.btn_1);
    Button btn2 = getDialog().findViewById(R.id.btn_2);
    Button btn3 = getDialog().findViewById(R.id.btn_3);

    if (mGoalCompleteResult != Goal.GoalCompleteResult.Pending) {
        btn1.setText(getString(R.string.fail));
        btn1.setTextColor(ContextCompat.getColor(getContext(), R.color.red));
        btn1.setTag(Goal.GoalCompleteResult.Failed);
        btn1.setOnClickListener(updateAction);

        btn2.setVisibility(View.VISIBLE);
        btn2.setText(getString(R.string.pass));
        btn2.setTextColor(ContextCompat.getColor(getContext(), R.color.green));
        btn2.setTag(Goal.GoalCompleteResult.Success);
        btn2.setOnClickListener(updateAction);

        btn3.setVisibility(View.VISIBLE);
        btn3.setText(getString(R.string.remind_friend));
        btn3.setTextColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
        btn3.setOnClickListener(remindAction);
    } else {
        btn1.setText(getString(R.string.accept));
        btn1.setTextColor(ContextCompat.getColor(getContext(), R.color.green));
        btn1.setTag(Goal.GoalCompleteResult.Ongoing);
        btn1.setOnClickListener(updateAction);

        btn2.setVisibility(View.GONE); //No decline for now until server adds implemention
        btn3.setVisibility(View.GONE);
    }
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:32,代码来源:GoalsDetailedDialog.java

示例11: getView

import android.widget.Button; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	if (null == convertView) {
		LayoutInflater factory = LayoutInflater.from(MainActivity.this);
		View mView = factory.inflate(R.layout.list_items, null);
		convertView = mView;
	}
	
	Button btn = (Button) convertView.findViewById(R.id.btn);
	btn.setOnClickListener(MainActivity.this);
	btn.setTag(position);
	btn.setText(items[position]);
	
	return convertView;
}
 
开发者ID:SoulEaterVTT,项目名称:KotlinStudy,代码行数:16,代码来源:MainActivity.java

示例12: refreshWordSelector

import android.widget.Button; //导入方法依赖的package包/类
public void refreshWordSelector()	{
LinkedList<String> listMatched = minputMethodCaller.matchFuncVars(mstrBuffered);
	mwordSelectionContainer.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, mnInputBtnHeight));		
mlLayoutWordSelectionBtnHolder.removeAllViews();
for (int idx = 0 ; idx < listMatched.size(); idx ++)	{
	String str = listMatched.get(idx);
	Button btn = new Button(getContext());
	btn.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, mnInputBtnHeight));
	btn.setTag(str);
	btn.setText(str);
	btn.setTextSize(TypedValue.COMPLEX_UNIT_PX, mfTextSize);
	int nTextColor = Color.RED;
	if (idx > 0)	{
		nTextColor = Color.GREEN;
	}
	btn.setTextColor(nTextColor);
	btn.setBackgroundResource(R.drawable.btn_background);
	btn.setOnClickListener(new OnClickListener()	{

		@Override
		public void onClick(View v) {
			minputMethodCaller.onClickSelectedWord((String)v.getTag());
		}
		
	});
	mlLayoutWordSelectionBtnHolder.addView(btn);
}	
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:29,代码来源:AMInputMethod.java

示例13: setButtonTag

import android.widget.Button; //导入方法依赖的package包/类
public final ECAlertDialog setButtonTag(int id , OnClickListener listener) {
    Button button = mButtons.get(id);
    button.setTag(listener);
    return this;
}
 
开发者ID:NewCasino,项目名称:browser,代码行数:6,代码来源:ECAlertDialog.java

示例14: onCreate

import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scan);
    setTitle(R.string.category_scan_for_devices);

    wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
    requestQueue = Volley.newRequestQueue(this);

    final Toolbar toolbar = findViewById(R.id.toolbarScan);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    if (wifiManager != null && wifiManager.isWifiEnabled() && wifiManager.getConnectionInfo() != null && null != wifiManager.getConnectionInfo().getSSID()) {
        List<DeviceDAO> devices = db.getDevicesBySSID(wifiManager.getConnectionInfo().getSSID());
        for (DeviceDAO deviceDAO : devices) {
            existingDevices.put(deviceDAO.getIP(), deviceDAO);
            LinearLayout detectedDevicesLayout = findViewById(R.id.detectedDevicesLayout);
            View card = getLayoutInflater().inflate(R.layout.scan_activity_card_device, detectedDevicesLayout, false);

            Button selectDevice = card.findViewById(R.id.select_device);
            selectDevice.setTag(R.id.cardDevice, deviceDAO);

            cards.append(deviceDAO.getId(), card);
            TextView name = card.findViewById(R.id.name);
            if (deviceDAO.getName() != null && !deviceDAO.getName().isEmpty()) {
                name.setText(deviceDAO.getName());
            }
            TextView ip = card.findViewById(R.id.ip);
            ip.setText(String.format("%s%s", getResources().getString(R.string.ip_label), deviceDAO.getIP()));
            if (deviceDAO.getVendor() != null) {
                TextView vendor = card.findViewById(R.id.vendor);
                vendor.setText(deviceDAO.getVendor());
            }
            detectedDevicesLayout.addView(card);
        }
    }

    FloatingActionButton fab = findViewById(R.id.addDeviceFab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent();
            intent.putParcelableArrayListExtra(Constants.EXTRA_DEVICES, pendingDevices);
            setResult(RESULT_OK, intent);
            finish();
        }
    });
    startDiscovery();
}
 
开发者ID:MBach,项目名称:home-automation,代码行数:53,代码来源:ScanActivity.java

示例15: makeEtcMedicineList

import android.widget.Button; //导入方法依赖的package包/类
private void makeEtcMedicineList(){

        li_etcList.removeAllViews();

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

            if(takeMedicines.get(i).getPatientMedicine() == null) {

                Medicine medicine = takeMedicines.get(i).getMedicine();

                View v = getLayoutInflater().inflate(R.layout.medicine_list_custom_item, null, false);

                TextView tv_name = (TextView) v.findViewById(R.id.tv_name);
                tv_name.setGravity(View.TEXT_ALIGNMENT_CENTER);
                TextView tv_code = (TextView) v.findViewById(R.id.tv_code);
                tv_code.setGravity(View.TEXT_ALIGNMENT_CENTER);
                Button btn_select = (Button) v.findViewById(R.id.btn_select);

                tv_name.setText(medicine.getNameSrt(30));
                tv_code.setText(medicine.getCode());

                btn_select.setBackgroundResource(R.drawable.two_btn_active_right_radius_red);
                btn_select.setText(R.string.delete_srt);
                btn_select.setTag(i);
                btn_select.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        int index = (int) view.getTag();
                        takeMedicines.remove(index);
                        makeEtcMedicineList();
                    }
                });

                li_etcList.addView(v);

            }

        }

//        for(int i=0; i<etcMedicines.size(); i++){
//
//            Medicine medicine = etcMedicines.get(i);
//
//            View v = getLayoutInflater().inflate(R.layout.medicine_list_custom_item, null, false);
//
//            TextView tv_name = (TextView)v.findViewById(R.id.tv_name);
//            tv_name.setGravity(View.TEXT_ALIGNMENT_CENTER);
//            TextView tv_code = (TextView)v.findViewById(R.id.tv_code);
//            tv_code.setGravity(View.TEXT_ALIGNMENT_CENTER);
//            Button btn_select = (Button)v.findViewById(R.id.btn_select);
//
//            tv_name.setText(medicine.getNameSrt(30));
//            tv_code.setText(medicine.getCode());
//
//            btn_select.setBackgroundResource(R.drawable.two_btn_active_right_radius_red);
//            btn_select.setText(R.string.delete_srt);
//            btn_select.setTag(i);
//            btn_select.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//                    int index = (int)view.getTag();
//                    etcMedicines.remove(index);
//                    makeEtcMedicineList();
//                }
//            });
//
//            li_etcList.addView(v);
//
//        }


    }
 
开发者ID:pooi,项目名称:Nearby,代码行数:73,代码来源:RecordMedicineActivity.java


注:本文中的android.widget.Button.setTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。