Java Code Examples for android.widget.Button#setTag()

The following examples show how to use android.widget.Button#setTag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FolderDialog.java    From DroidPlay with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initialize the dialog.
 * 
 * @param context The application context
 * @param callback The callback
 * @param currentFolder The base folder
 */
public FolderDialog(Context context, DialogCallback callback, File currentFolder) {
	super(context);
	setTitle("Select Folder");
	this.callback = callback;
	this.currentFolder = currentFolder;
	setContentView(R.layout.folder);

	adapter = new FolderListAdapter(getContext(), new ArrayList<File>());
	refresh();
	
	ListView list = (ListView) findViewById(R.id.list);
	list.setAdapter(adapter);
	list.setOnItemClickListener(this);
	
	Button cancel = (Button) findViewById(R.id.cancel);
	cancel.setTag("cancel");
	cancel.setOnClickListener(this);
	
	Button select = (Button) findViewById(R.id.select);
	select.setTag("select");
	select.setOnClickListener(this);
}
 
Example 2
Source File: AuthenticationErrorActivity.java    From product-emm with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_authentication_error);
	Bundle extras = getIntent().getExtras();
	if (extras != null) {
		if (extras.containsKey(getResources().getString(R.string.intent_extra_regid))) {
			registrationId =
					extras.getString(getResources().getString(R.string.intent_extra_regid));
		}

		if (extras.containsKey(getResources().getString(R.string.intent_extra_from_activity))) {
			fromActivity =
					extras.getString(
							getResources().getString(R.string.intent_extra_from_activity));
		}
	}
	
	txtMessage = (TextView) findViewById(R.id.error);

	btnTryAgain = (Button) findViewById(R.id.btnTryAgain);
	btnTryAgain.setTag(TAG_BTN_TRY_AGAIN);
	btnTryAgain.setOnClickListener(onClickListener_BUTTON_CLICKED);

	if (fromActivity.equals(RegistrationActivity.class.getSimpleName())) {
		txtMessage.setText(getResources().getString(R.string.error_registration_failed));
	} else if (fromActivity.equals(AlreadyRegisteredActivity.class.getSimpleName())) {
		txtMessage.setText(getResources().getString(R.string.error_unregistration_failed));
		btnTryAgain.setTag(TAG_BTN_UNREGISTER);
	}

}
 
Example 3
Source File: GroupActivity.java    From gcm with Apache License 2.0 5 votes vote down vote up
private View createCurrentMemberRow(String name, String value) {
    LinearLayout row = (LinearLayout) getLayoutInflater()
            .inflate(R.layout.widget_icon_text_button_row, null);
    ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
    TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
    Button button = (Button) row.findViewById(R.id.widget_itbr_button);

    icon.setImageResource(R.drawable.smartphone_grey600);
    label.setText(name + ": " + AbstractFragment.truncateToShortString(value));
    button.setText(R.string.group_remove_member);
    button.setTag(R.id.tag_action, ACTION_REMOVE_MEMBER);
    button.setTag(R.id.tag_token, name);
    button.setOnClickListener(this);
    return row;
}
 
Example 4
Source File: GroupActivity.java    From gcm with Apache License 2.0 5 votes vote down vote up
private View createRemovedMemberRow(String name, String value) {
    LinearLayout row = (LinearLayout) getLayoutInflater()
            .inflate(R.layout.widget_icon_text_button_row, null);
    ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
    TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
    Button button = (Button) row.findViewById(R.id.widget_itbr_button);

    icon.setImageResource(R.drawable.smartphone_grey600);
    label.setText(name + ": " + AbstractFragment.truncateToShortString(value));
    button.setText(R.string.group_undo_remove_member);
    button.setTag(R.id.tag_action, ACTION_UNDO_REMOVE_MEMBER);
    button.setTag(R.id.tag_token, name);
    button.setOnClickListener(this);
    return row;
}
 
Example 5
Source File: EventPageACTIVITY.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
/**
 * 添加活动评论
 * @param arg0
 */
private void addEventCommentVo(EventCommentVo arg0) {
	LayoutInflater inflater = getLayoutInflater();	// 通过inflate方法将layout转化为view
	View layout = inflater.inflate(R.layout.list_eventcomments, null);
	TextView textView_eventcomments_UName = (TextView)layout.findViewById(R.id.textView_eventcomments_UName);
	TextView textView_eventcomments_ReplyUName = (TextView)layout.findViewById(R.id.textView_eventcomments_ReplyUName);
	TextView textView_eventcomments_Texts = (TextView)layout.findViewById(R.id.textView_eventcomments_Texts);
	TextView TextView_eventcomments_AddTime = (TextView)layout.findViewById(R.id.TextView_eventcomments_SendTime);
	ImageView imageView_eventcomment_userhead = (ImageView)layout.findViewById(R.id.imageView_eventcomment_userhead);
	Button button_comments = (Button)layout.findViewById(R.id.button_eventcomments);
	button_comments.setTag(arg0);
	button_comments.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			//显示评论窗口
			EventCommentVo i = (EventCommentVo)v.getTag();

			SharedPreferences share = EventPageACTIVITY.this.getSharedPreferences("userdata", Context.MODE_PRIVATE);
			AddCommentDialogFRAGMENT newFragment = AddCommentDialogFRAGMENT.newInstance("addComment");
			newFragment.setValue(share.getInt("uid", -1),eventdata.getEid(),share.getString("uname", ""),i.getUid(),i.getUname(),eventPageLogic);
	        newFragment.show(getSupportFragmentManager(), "dialog");
	        
		}
	});
	
	textView_eventcomments_UName.setText(arg0.getUname() + ":");
	
	if(arg0.getReplyuname() != null&&!arg0.getReplyuname().equals("")) {
		textView_eventcomments_ReplyUName.setText("回复" + arg0.getReplyuname()  + ":");
	}else {
		textView_eventcomments_ReplyUName.setVisibility(View.GONE);
	}
	textView_eventcomments_Texts.setText(arg0.getTexts());
	TextView_eventcomments_AddTime.setText(DateUtil.showDate(arg0.getSendtime()));
	imageUtil.displayAvatar(imageView_eventcomment_userhead, arg0.getUid());
	
	LinearLayout_EventComments.addView(layout);
}
 
Example 6
Source File: IMSingleNumber.java    From opensudoku with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected View createControlPanelView() {
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View controlPanel = inflater.inflate(R.layout.im_single_number, null);

    mNumberButtons = new HashMap<>();
    mNumberButtons.put(1, controlPanel.findViewById(R.id.button_1));
    mNumberButtons.put(2, controlPanel.findViewById(R.id.button_2));
    mNumberButtons.put(3, controlPanel.findViewById(R.id.button_3));
    mNumberButtons.put(4, controlPanel.findViewById(R.id.button_4));
    mNumberButtons.put(5, controlPanel.findViewById(R.id.button_5));
    mNumberButtons.put(6, controlPanel.findViewById(R.id.button_6));
    mNumberButtons.put(7, controlPanel.findViewById(R.id.button_7));
    mNumberButtons.put(8, controlPanel.findViewById(R.id.button_8));
    mNumberButtons.put(9, controlPanel.findViewById(R.id.button_9));
    mNumberButtons.put(0, controlPanel.findViewById(R.id.button_clear));

    for (Integer num : mNumberButtons.keySet()) {
        Button b = mNumberButtons.get(num);
        b.setTag(num);
        b.setOnClickListener(mNumberButtonClicked);
        b.setOnTouchListener(mNumberButtonTouched);
    }

    mSwitchNumNoteButton = controlPanel.findViewById(R.id.switch_num_note);
    mSwitchNumNoteButton.setOnClickListener(v -> {
        mEditMode = mEditMode == MODE_EDIT_VALUE ? MODE_EDIT_NOTE : MODE_EDIT_VALUE;
        update();
    });

    return controlPanel;
}
 
Example 7
Source File: WelcomeGuideActivity.java    From A-week-to-develop-android-app-plan with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_guide);

	views = new ArrayList<View>();

	// 初始化引导页视图列表
	for (int i = 0; i < pics.length; i++) {
		View view = LayoutInflater.from(this).inflate(pics[i], null);
		
		if (i == pics.length - 1) {
			startBtn = (Button) view.findViewById(R.id.btn_login);
			startBtn.setTag("enter");
			startBtn.setOnClickListener(this);
		}
		
		views.add(view);

	}

	vp = (ViewPager) findViewById(R.id.vp_guide);
	// 初始化adapter
	adapter = new GuideViewPagerAdapter(views);
	vp.setAdapter(adapter);
	vp.setOnPageChangeListener(new PageChangeListener());

	initDots();
	
}
 
Example 8
Source File: AppRestrictionEnforcerFragment.java    From android-AppRestrictionEnforcer with Apache License 2.0 5 votes vote down vote up
private void insertItemRow(LayoutInflater inflater, String key, String value) {
    View view = inflater.inflate(R.layout.item, mLayoutItems, false);
    TextView textView = (TextView) view.findViewById(R.id.item_text);
    textView.setText(getString(R.string.item, key, value));
    Button remove = (Button) view.findViewById(R.id.item_remove);
    remove.setTag(key);
    remove.setOnClickListener(this);
    mLayoutItems.addView(view);
}
 
Example 9
Source File: SubjectMenuActivity.java    From Primary with GNU General Public License v3.0 5 votes vote down vote up
private void showLevelButtons() {
    int highest = mUserData.getSubjectForUser(mSubjectCode).getHighestLevelNum();

    LinearLayout button_layout = findViewById(R.id.button_layout);

    button_layout.removeAllViews();

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER_VERTICAL;

    for (Level level : mSubject.getLevels()) {

        LinearLayout levelrow = new LinearLayout(this);
        levelrow.setOrientation(LinearLayout.HORIZONTAL);
        button_layout.addView(levelrow);

        Button levelbutt = new Button(this);
        levelbutt.setLayoutParams(lp);
        levelbutt.setText(getString(R.string.level, level.getLevelNum()));
        levelbutt.setTag(level.getLevelNum() - 1);
        levelbutt.setOnClickListener(this);
        levelrow.addView(levelbutt);

        TextView desc = new TextView(this);
        desc.setText(level.getDescription(this));
        desc.setLayoutParams(lp);
        desc.setTextSize(16);
        levelrow.addView(desc);

        boolean beenthere = level.getLevelNum() - 1 <= highest;
        levelbutt.setEnabled(beenthere);
        desc.setEnabled(beenthere);
    }
}
 
Example 10
Source File: AuthenticationErrorActivity.java    From product-emm with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_authentication_error);
	Bundle extras = getIntent().getExtras();
	if (extras != null) {
		if (extras.containsKey(getResources().getString(R.string.intent_extra_regid))) {
			registrationId =
					extras.getString(getResources().getString(R.string.intent_extra_regid));
		}

		if (extras.containsKey(getResources().getString(R.string.intent_extra_from_activity))) {
			fromActivity =
					extras.getString(
							getResources().getString(R.string.intent_extra_from_activity));
		}
	}
	
	if (registrationId == null || registrationId.isEmpty()) {
		registrationId = GCMRegistrar.getRegistrationId(this);
	}
	
	txtMessage = (TextView) findViewById(R.id.error);

	btnTryAgain = (Button) findViewById(R.id.btnTryAgain);
	btnTryAgain.setTag(TAG_BTN_TRY_AGAIN);
	btnTryAgain.setOnClickListener(onClickListener_BUTTON_CLICKED);

	if (fromActivity.equals(RegistrationActivity.class.getSimpleName())) {
		txtMessage.setText(getResources().getString(R.string.error_registration_failed));
	} else if (fromActivity.equals(AlreadyRegisteredActivity.class.getSimpleName())) {
		txtMessage.setText(getResources().getString(R.string.error_unregistration_failed));
		btnTryAgain.setTag(TAG_BTN_UNREGISTER);
	}

}
 
Example 11
Source File: AboutAty.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
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;
		}
	});
}
 
Example 12
Source File: ImagePickerFactory.java    From android-json-form-wizard with MIT License 5 votes vote down vote up
@Override
public List<View> getViewsFromJson(String stepName, Context context, JSONObject jsonObject, CommonListener listener) throws Exception {
    List<View> views = new ArrayList<>(1);
    ImageView imageView = new ImageView(context);
    imageView.setImageDrawable(context.getResources().getDrawable(R.mipmap.grey_bg));
    imageView.setTag(R.id.key, jsonObject.getString("key"));
    imageView.setTag(R.id.type, jsonObject.getString("type"));

    JSONObject requiredObject = jsonObject.optJSONObject("v_required");
    if (requiredObject != null) {
        String requiredValue = requiredObject.getString("value");
        if (!TextUtils.isEmpty(requiredValue)) {
            imageView.setTag(R.id.v_required, requiredValue);
            imageView.setTag(R.id.error, requiredObject.optString("err"));
        }
    }

    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    imageView.setLayoutParams(getLayoutParams(MATCH_PARENT, dpToPixels(context, 200), 0, 0, 0, (int) context
            .getResources().getDimension(R.dimen.default_bottom_margin)));
    String imagePath = jsonObject.optString("value");
    if (!TextUtils.isEmpty(imagePath)) {
        imageView.setTag(R.id.imagePath, imagePath);
        imageView.setImageBitmap(ImageUtils.loadBitmapFromFile(imagePath, ImageUtils.getDeviceWidth(context), dpToPixels(context, 200)));
    }
    views.add(imageView);
    Button uploadButton = new Button(context);
    uploadButton.setText(jsonObject.getString("uploadButtonText"));
    uploadButton.setLayoutParams(getLayoutParams(WRAP_CONTENT, WRAP_CONTENT, 0, 0, 0, (int) context
            .getResources().getDimension(R.dimen.default_bottom_margin)));
    uploadButton.setOnClickListener(listener);
    uploadButton.setTag(R.id.key, jsonObject.getString("key"));
    uploadButton.setTag(R.id.type, jsonObject.getString("type"));
    views.add(uploadButton);
    return views;
}
 
Example 13
Source File: IMNumpad.java    From opensudoku with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected View createControlPanelView() {
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View controlPanel = inflater.inflate(R.layout.im_numpad, null);

    mNumberButtons = new HashMap<>();
    mNumberButtons.put(1, controlPanel.findViewById(R.id.button_1));
    mNumberButtons.put(2, controlPanel.findViewById(R.id.button_2));
    mNumberButtons.put(3, controlPanel.findViewById(R.id.button_3));
    mNumberButtons.put(4, controlPanel.findViewById(R.id.button_4));
    mNumberButtons.put(5, controlPanel.findViewById(R.id.button_5));
    mNumberButtons.put(6, controlPanel.findViewById(R.id.button_6));
    mNumberButtons.put(7, controlPanel.findViewById(R.id.button_7));
    mNumberButtons.put(8, controlPanel.findViewById(R.id.button_8));
    mNumberButtons.put(9, controlPanel.findViewById(R.id.button_9));
    mNumberButtons.put(0, controlPanel.findViewById(R.id.button_clear));

    for (Integer num : mNumberButtons.keySet()) {
        Button b = mNumberButtons.get(num);
        b.setTag(num);
        b.setOnClickListener(mNumberButtonClick);
    }

    mSwitchNumNoteButton = controlPanel.findViewById(R.id.switch_num_note);
    mSwitchNumNoteButton.setOnClickListener(v -> {
        mEditMode = mEditMode == MODE_EDIT_VALUE ? MODE_EDIT_NOTE : MODE_EDIT_VALUE;
        update();
    });

    return controlPanel;

}
 
Example 14
Source File: Phonebook_myAdapter.java    From ui with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
    Phonebook_DataModel entry = listPhonebook.get(position);
    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.phonebook_rowlayout, null);
    }
    TextView tvContact = (TextView) convertView.findViewById(R.id.tvContact);
    tvContact.setText(entry.getName());

    TextView tvPhone = (TextView) convertView.findViewById(R.id.tvMobile);
    tvPhone.setText(entry.getPhone());

    TextView tvMail = (TextView) convertView.findViewById(R.id.tvMail);
    tvMail.setText(entry.getMail());

    // Set the onClick Listener on this button
    Button btnRemove = (Button) convertView.findViewById(R.id.btnRemove);
    btnRemove.setFocusableInTouchMode(false);
    btnRemove.setFocusable(false);
    btnRemove.setOnClickListener(this);
    // Set the entry, so that you can capture which item was clicked and
    // then remove it
    // As an alternative, you can use the id/position of the item to capture
    // the item that was clicked.
    // btnRemove.setId(position);

    btnRemove.setTag(entry);

    

    return convertView;
}
 
Example 15
Source File: ProjectAdapter.java    From microbit with Apache License 2.0 4 votes vote down vote up
@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 16
Source File: OptionsPickerView.java    From Android-PickerView with Apache License 2.0 4 votes vote down vote up
private void initView(Context context) {
    setDialogOutSideCancelable();
    initViews();
    initAnim();
    initEvents();
    if (mPickerOptions.customListener == null) {
        LayoutInflater.from(context).inflate(mPickerOptions.layoutRes, contentContainer);

        //顶部标题
        TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
        RelativeLayout rv_top_bar = (RelativeLayout) findViewById(R.id.rv_topbar);

        //确定和取消按钮
        Button btnSubmit = (Button) findViewById(R.id.btnSubmit);
        Button btnCancel = (Button) findViewById(R.id.btnCancel);

        btnSubmit.setTag(TAG_SUBMIT);
        btnCancel.setTag(TAG_CANCEL);
        btnSubmit.setOnClickListener(this);
        btnCancel.setOnClickListener(this);

        //设置文字
        btnSubmit.setText(TextUtils.isEmpty(mPickerOptions.textContentConfirm) ? context.getResources().getString(R.string.pickerview_submit) : mPickerOptions.textContentConfirm);
        btnCancel.setText(TextUtils.isEmpty(mPickerOptions.textContentCancel) ? context.getResources().getString(R.string.pickerview_cancel) : mPickerOptions.textContentCancel);
        tvTitle.setText(TextUtils.isEmpty(mPickerOptions.textContentTitle) ? "" : mPickerOptions.textContentTitle);//默认为空

        //设置color
        btnSubmit.setTextColor(mPickerOptions.textColorConfirm);
        btnCancel.setTextColor(mPickerOptions.textColorCancel);
        tvTitle.setTextColor(mPickerOptions.textColorTitle);
        rv_top_bar.setBackgroundColor(mPickerOptions.bgColorTitle);

        //设置文字大小
        btnSubmit.setTextSize(mPickerOptions.textSizeSubmitCancel);
        btnCancel.setTextSize(mPickerOptions.textSizeSubmitCancel);
        tvTitle.setTextSize(mPickerOptions.textSizeTitle);
    } else {
        mPickerOptions.customListener.customLayout(LayoutInflater.from(context).inflate(mPickerOptions.layoutRes, contentContainer));
    }

    // ----滚轮布局
    final LinearLayout optionsPicker = (LinearLayout) findViewById(R.id.optionspicker);
    optionsPicker.setBackgroundColor(mPickerOptions.bgColorWheel);

    wheelOptions = new WheelOptions<>(optionsPicker, mPickerOptions.isRestoreItem);
    if (mPickerOptions.optionsSelectChangeListener != null) {
        wheelOptions.setOptionsSelectChangeListener(mPickerOptions.optionsSelectChangeListener);
    }

    wheelOptions.setTextContentSize(mPickerOptions.textSizeContent);
    wheelOptions.setItemsVisible(mPickerOptions.itemsVisibleCount);
    wheelOptions.setAlphaGradient(mPickerOptions.isAlphaGradient);
    wheelOptions.setLabels(mPickerOptions.label1, mPickerOptions.label2, mPickerOptions.label3);
    wheelOptions.setTextXOffset(mPickerOptions.x_offset_one, mPickerOptions.x_offset_two, mPickerOptions.x_offset_three);
    wheelOptions.setCyclic(mPickerOptions.cyclic1, mPickerOptions.cyclic2, mPickerOptions.cyclic3);
    wheelOptions.setTypeface(mPickerOptions.font);

    setOutSideCancelable(mPickerOptions.cancelable);

    wheelOptions.setDividerColor(mPickerOptions.dividerColor);
    wheelOptions.setDividerType(mPickerOptions.dividerType);
    wheelOptions.setLineSpacingMultiplier(mPickerOptions.lineSpacingMultiplier);
    wheelOptions.setTextColorOut(mPickerOptions.textColorOut);
    wheelOptions.setTextColorCenter(mPickerOptions.textColorCenter);
    wheelOptions.isCenterLabel(mPickerOptions.isCenterLabel);
}
 
Example 17
Source File: PlusMinusNum.java    From K-Sonic with MIT License 4 votes vote down vote up
private void initView() {
    setOrientation(LinearLayout.HORIZONTAL);

    // =========@center Layout
    centerLL = new LinearLayout(getContext());
    editText = new EditText(getContext());
    editText.setInputType(InputType.TYPE_CLASS_NUMBER);//TYPE_NULL
    editText.setText(String.valueOf(num));
    editText.setTextColor(0xff229EBF);
    editText.setBackgroundResource(R.drawable.num_edit);
    editText.setPadding(0, 0, 0, 0);
    editText.setGravity(Gravity.CENTER);
    editText.setMinimumWidth(ediTextMinimumWidth);
    LayoutParams ediTextLP = new LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    editText.setLayoutParams(ediTextLP);

    LayoutParams centerLP = new LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    centerLP.gravity = Gravity.CENTER;
    centerLL.setLayoutParams(centerLP);
    centerLL.setFocusable(true);
    centerLL.setFocusableInTouchMode(true);


    // =========@left/right Layout
    minusButton = new Button(getContext());
    minusButton.setText(minusButtonText);
    minusButton.setTextColor(0xff666666);
    minusButton.setTag(minusButtonText);
    minusButton.setBackgroundResource(R.drawable.num_minus);
    minusButton.setPadding(0, 0, 0, 0);

    plusButton = new Button(getContext());
    plusButton.setText(plusButtonText);
    plusButton.setTextColor(0xff666666);
    plusButton.setTag(plusButtonText);
    plusButton.setBackgroundResource(R.drawable.num_plus);
    plusButton.setPadding(0, 0, 0, 0);

    LayoutParams buttonLP = new LayoutParams(
            buttonWidth,
            LinearLayout.LayoutParams.MATCH_PARENT);
    plusButton.setLayoutParams(buttonLP);
    minusButton.setLayoutParams(buttonLP);
}
 
Example 18
Source File: TimePickerView.java    From Android-PickerView with Apache License 2.0 4 votes vote down vote up
private void initView(Context context) {
    setDialogOutSideCancelable();
    initViews();
    initAnim();

    if (mPickerOptions.customListener == null) {
        LayoutInflater.from(context).inflate(R.layout.pickerview_time, contentContainer);

        //顶部标题
        TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
        RelativeLayout rv_top_bar = (RelativeLayout) findViewById(R.id.rv_topbar);

        //确定和取消按钮
        Button btnSubmit = (Button) findViewById(R.id.btnSubmit);
        Button btnCancel = (Button) findViewById(R.id.btnCancel);

        btnSubmit.setTag(TAG_SUBMIT);
        btnCancel.setTag(TAG_CANCEL);

        btnSubmit.setOnClickListener(this);
        btnCancel.setOnClickListener(this);

        //设置文字
        btnSubmit.setText(TextUtils.isEmpty(mPickerOptions.textContentConfirm) ? context.getResources().getString(R.string.pickerview_submit) : mPickerOptions.textContentConfirm);
        btnCancel.setText(TextUtils.isEmpty(mPickerOptions.textContentCancel) ? context.getResources().getString(R.string.pickerview_cancel) : mPickerOptions.textContentCancel);
        tvTitle.setText(TextUtils.isEmpty(mPickerOptions.textContentTitle) ? "" : mPickerOptions.textContentTitle);//默认为空

        //设置color
        btnSubmit.setTextColor(mPickerOptions.textColorConfirm);
        btnCancel.setTextColor(mPickerOptions.textColorCancel);
        tvTitle.setTextColor(mPickerOptions.textColorTitle);
        rv_top_bar.setBackgroundColor(mPickerOptions.bgColorTitle);

        //设置文字大小
        btnSubmit.setTextSize(mPickerOptions.textSizeSubmitCancel);
        btnCancel.setTextSize(mPickerOptions.textSizeSubmitCancel);
        tvTitle.setTextSize(mPickerOptions.textSizeTitle);

    } else {
        mPickerOptions.customListener.customLayout(LayoutInflater.from(context).inflate(mPickerOptions.layoutRes, contentContainer));
    }
    // 时间转轮 自定义控件
    LinearLayout timePickerView = (LinearLayout) findViewById(R.id.timepicker);
    timePickerView.setBackgroundColor(mPickerOptions.bgColorWheel);

    initWheelTime(timePickerView);
}
 
Example 19
Source File: ValidationBindings.java    From convalida with Apache License 2.0 4 votes vote down vote up
@BindingAdapter(value = "validationAction")
public static void validationActionBindings(Button button, Integer action) {
    button.setTag(R.id.validation_action, action);
}
 
Example 20
Source File: TimePickerView.java    From AndroidFrame with Apache License 2.0 4 votes vote down vote up
private void initView(Context context) {
    setDialogOutSideCancelable(cancelable);
    initViews(backgroundId);
    init();
    initEvents();
    if (customListener == null) {
        LayoutInflater.from(context).inflate(R.layout.pickerview_time, contentContainer);

        //顶部标题
        tvTitle = (TextView) findViewById(R.id.tvTitle);

        //确定和取消按钮
        btnSubmit = (Button) findViewById(R.id.btnSubmit);
        btnCancel = (Button) findViewById(R.id.btnCancel);

        btnSubmit.setTag(TAG_SUBMIT);
        btnCancel.setTag(TAG_CANCEL);

        btnSubmit.setOnClickListener(this);
        btnCancel.setOnClickListener(this);

        //设置文字
        btnSubmit.setText(TextUtils.isEmpty(Str_Submit) ? context.getResources().getString(R.string.pickerview_submit) : Str_Submit);
        btnCancel.setText(TextUtils.isEmpty(Str_Cancel) ? context.getResources().getString(R.string.pickerview_cancel) : Str_Cancel);
        tvTitle.setText(TextUtils.isEmpty(Str_Title) ? "" : Str_Title);//默认为空

        //设置文字颜色
        btnSubmit.setTextColor(Color_Submit == 0 ? pickerview_timebtn_nor : Color_Submit);
        btnCancel.setTextColor(Color_Cancel == 0 ? pickerview_timebtn_nor : Color_Cancel);
        tvTitle.setTextColor(Color_Title == 0 ? pickerview_topbar_title : Color_Title);

        //设置文字大小
        btnSubmit.setTextSize(Size_Submit_Cancel);
        btnCancel.setTextSize(Size_Submit_Cancel);
        tvTitle.setTextSize(Size_Title);
        RelativeLayout rv_top_bar = (RelativeLayout) findViewById(R.id.rv_topbar);
        rv_top_bar.setBackgroundColor(Color_Background_Title == 0 ? pickerview_bg_topbar : Color_Background_Title);
    } else {
        customListener.customLayout(LayoutInflater.from(context).inflate(layoutRes, contentContainer));
    }
    // 时间转轮 自定义控件
    LinearLayout timePickerView = (LinearLayout) findViewById(R.id.timepicker);

    timePickerView.setBackgroundColor(Color_Background_Wheel == 0 ? bgColor_default : Color_Background_Wheel);

    wheelTime = new WheelTime(timePickerView, type, gravity, Size_Content);
    wheelTime.setLunarCalendar(isLunarCalendar);

    if (startYear != 0 && endYear != 0 && startYear <= endYear) {
        setRange();
    }

    if (startDate != null && endDate != null) {
        if (startDate.getTimeInMillis() <= endDate.getTimeInMillis()) {

            setRangDate();
        }
    } else if (startDate != null && endDate == null) {
        setRangDate();
    } else if (startDate == null && endDate != null) {
        setRangDate();
    }

    setTime();
    wheelTime.setLabels(label_year, label_month, label_day, label_hours, label_mins, label_seconds);
    wheelTime.setTextXOffset(xoffset_year, xoffset_month, xoffset_day, xoffset_hours, xoffset_mins, xoffset_seconds);

    setOutSideCancelable(cancelable);
    wheelTime.setCyclic(cyclic);
    wheelTime.setDividerColor(dividerColor);
    wheelTime.setDividerType(dividerType);
    wheelTime.setLineSpacingMultiplier(lineSpacingMultiplier);
    wheelTime.setTextColorOut(textColorOut);
    wheelTime.setTextColorCenter(textColorCenter);
    wheelTime.isCenterLabel(isCenterLabel);
}