當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。