button – Vários botões para abrir a mesma activity e mudar a textview em android

Olá pessoal estou a começar a programar em android.
Tenho vários botões em uma activity e preciso que em cada botões que eu clicar abre uma mesma activity e altera a textview

Eu tentei assim:

Activity1

t1.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
 Intent intent = new Intent(activity1.this, activity 2.class);
    String a = "vida";
                    
intent.putExtra("a", a); 
     startActivity(intent);
        }
    });
     
     t2.setOnClickListener(new View.OnClickListener() {
            
    public void onClick(View v) {
    Intent intent = new Intent(Activity1.this, Activity2.class);
String b = "Morte";
                        
intent.putExtra("b" ,b ); 
    startActivity(intent);            
                
            }
        });

Segunda activy

Intent intent = getIntent();
String t1 = intent.getStringExtra(“b”);
TextView tt1 = (TextView) findViewById(R.id.text);
tt1.setText(t1);

Intent intent1 = getIntent();
String t2 = intent.getStringExtra(“a”); TextView tt2 = (TextView) findViewById(R.id.text);
tt1.setText(t2);

Mas quando clico no segundo botão a activity2 aparece vazia.

magento 1.9 – I want set some functionalities on add_to_cart button

I am building E-Commerce website in Magento 1.9. I want to add below functionalities on my add_to_cart button on product page:

  1. Want to keep add_to_cart button disabled always

  2. I want every user check the zipcode first & if their zipcode is valid then only unfreeze the add_to_cart button, if the zipcode is invalid then keep the add_to_cart button disabled.

  3. Always refresh the product page whenever user checks zipcode & keep add_to_cart button disabled if zipcode is invalid & unfreeze if it is valid.

These exceptions are useful for me because I am running my E-Commerce store in limited area. I have attached the view.phtml, restriczip.phml & product page screenshot. If any more things needed please ask me. Thanks in advance.

view.phtml

<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<script type="text/javascript">
    var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
</script>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div>
<div class="product-view">
    <div class="product-essential">
        <form action="<?php echo $this->getSubmitUrlCustom($_product, array('_secure' => $this->_isSecure()), false) ?>"
              method="post"
              id="product_addtocart_form"
              <?php if ($_product->getOptions()): ?> enctype="multipart/form-data" <?php endif; ?>>
            <?php echo $this->getBlockHtml('formkey') ?>
            <div class="no-display">
                <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
                <input type="hidden" name="related_product" id="related-products-field" value="" />
            </div>

            <div class="product-img-box">
                <div class="product-name">
                    <h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
                </div>
                <?php echo $this->getChildHtml('media') ?>
            </div>

            <div class="product-shop">
                <div class="product-name">
                    <span class="h1"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></span>
                </div>

                <div class="price-info">
                    <?php echo $this->getPriceHtml($_product); ?>
                    <?php echo $this->getChildHtml('bundle_prices') ?>
                    <?php echo $this->getTierPriceHtml() ?>
                </div>

                <div class="extra-info">
                    <?php echo $this->getReviewsSummaryHtml($_product, 'default', false)?>
                    <?php echo $this->getChildHtml('product_type_availability'); ?>
                </div>

                <?php echo $this->getChildHtml('alert_urls') ?>

                <?php if ($_product->getShortDescription()):?>
                    <div class="short-description">
                        <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
                    </div>
                <?php endif;?>




                <?php echo $this->getChildHtml('other');?>

                <?php if ($_product->isSaleable() && $this->hasOptions()):?>
                    <?php echo $this->getChildChildHtml('container1', '', true, true) ?>
                <?php endif;?>

            </div>

            <div class="add-to-cart-wrapper">
                <?php echo $this->getChildHtml('product_type_data') ?>
                <?php echo $this->getChildHtml('extrahint') ?>

                <?php if (!$this->hasOptions()):?>
                    <div class="add-to-box">
                        <?php if($_product->isSaleable()): ?>
                            <?php echo $this->getChildHtml('addtocart') ?>
                            <?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
                                <span class="or"><?php echo $this->__('OR') ?></span>
                            <?php endif; ?>
                        <?php endif; ?>
                        <?php echo $this->getChildHtml('addto') ?>
                        <?php echo $this->getChildHtml('sharing') ?>
                    </div>
                    <?php echo $this->getChildHtml('extra_buttons') ?>
                <?php elseif (!$_product->isSaleable()): ?>
                    <div class="add-to-box">
                        <?php echo $this->getChildHtml('addto') ?>
                        <?php echo $this->getChildHtml('sharing') ?>
                    </div>
                <?php endif; ?>
            </div>

            <?php echo $this->getChildHtml('related_products') ?>

            <div class="clearer"></div>
            <?php if ($_product->isSaleable() && $this->hasOptions()):?>
                <?php echo $this->getChildChildHtml('container2', '', true, true) ?>
            <?php endif;?>
        </form>
        <script type="text/javascript">
        //<!(CDATA(
            var productAddToCartForm = new VarienForm('product_addtocart_form');
            productAddToCartForm.submit = function(button, url) {
                if (this.validator.validate()) {
                    var form = this.form;
                    var oldUrl = form.action;

                    if (url) {
                       form.action = url;
                    }
                    var e = null;
                    try {
                        this.form.submit();
                    } catch (e) {
                    }
                    this.form.action = oldUrl;
                    if (e) {
                        throw e;
                    }

                    if (button && button != 'undefined') {
                        button.disabled = true;
                    }
                }
            }.bind(productAddToCartForm);

            productAddToCartForm.submitLight = function(button, url){
                if(this.validator) {
                    var nv = Validation.methods;
                    delete Validation.methods('required-entry');
                    delete Validation.methods('validate-one-required');
                    delete Validation.methods('validate-one-required-by-name');
                    // Remove custom datetime validators
                    for (var methodName in Validation.methods) {
                        if (methodName.match(/^validate-datetime-.*/i)) {
                            delete Validation.methods(methodName);
                        }
                    }

                    if (this.validator.validate()) {
                        if (url) {
                            this.form.action = url;
                        }
                        this.form.submit();
                    }
                    Object.extend(Validation.methods, nv);
                }
            }.bind(productAddToCartForm);
        //))>
        </script>
    </div>

    <div class="product-collateral toggle-content tabs">
        <?php if ($detailedInfoGroup = $this->getChildGroup('detailed_info', 'getChildHtml')):?>
            <dl id="collateral-tabs" class="collateral-tabs">
                <?php foreach ($detailedInfoGroup as $alias => $html):?>
                    <dt class="tab"><span><?php echo $this->escapeHtml($this->getChildData($alias, 'title')) ?></span></dt>
                    <dd class="tab-container">
                        <div class="tab-content"><?php echo $html ?></div>
                    </dd>
                <?php endforeach;?>
            </dl>
        <?php endif; ?>
    </div>

    <?php echo $this->getChildHtml('upsell_products') ?>
    <?php echo $this->getChildHtml('product_additional_data') ?>

</div>

restrictzip.phtml

<div id="meetanshi-restrictzip">
    <ul class="messages cod-available">
        <li class="success-msg">
            <ul>
                <li>
                    <span>
                    <?php echo $this->__(Mage::helper('restrictzip')->getSuccessMsg()) ?> 
                    </span>
                </li>
            </ul>
        </li>
    </ul>
    <ul class="messages cod-available">
        <li class="success-msg"   style="display:<?php echo Mage::helper('restrictzip')->isShowDelivery();?>">
            <ul>
                <li><span id="extpected_delivery_time"> </span>
                </li>
            </ul>
        </li>
    </ul>
    <ul class="messages cod-not-available">
        <li class="error-msg">
            <ul>
                <li><span>
                        <?php echo $this->__(Mage::helper('restrictzip')->getErrorMsg()) ?>
                    </span>
                </li>
            </ul>
        </li>
    </ul>
    <ul class="messages cod-validation">
        <li class="error-msg">
            <ul>
                <li><span><?php echo $this->__('Please enter a ZIP code.')?></span></li>
            </ul>
        </li>
    </ul>
    <ul class="messages cod-error">
        <li class="error-msg">
            <ul>
                <li>
                    <span>
                        <?php echo $this->__('There was a problem while checking for COD availability. 
                        Please try again after some time.')?>
                    </span>
                </li>
            </ul>
        </li>
    </ul>
    <h4>
        <?php echo $this->__(Mage::helper('restrictzip')->getTitle())?>
    </h4>
    <label for="meetanshi-zip"><?php echo $this->__('ZIP Code')?></label>
    <input id="meetanshi-zip" type="text" name="zip_code" value="" maxlength="10" class="input-text"/>

    <button class="button check-zip" type="button" class="button"><span><span><?php echo $this->__('Check')?></span></span></button>

    <img src="<?php echo $this->getSkinUrl('meetanshi/loading.gif'); ?>" width="20" height="20"
         alt="" class="loading-spinner"/>
</div>
<script type="text/javascript">
    var meetanshi_restrictzip_ajax_url = '<?php echo $this->getUrl('restrictzip/restrictzip'); ?>';
</script>

<style>
#meetanshi-restrictzip {
    padding: 15px;
    border: 1px solid #CCC;
    margin-bottom: 15px;
}
#meetanshi-restrictzip .input-text {
  height: 38px;
  width: 100px;
}
.button.check-zip {
  height: 38px;
}
#meetanshi-restrictzip .cod-available,
#meetanshi-restrictzip .cod-not-available,
#meetanshi-restrictzip .cod-validation,
#meetanshi-restrictzip .cod-error,
#meetanshi-restrictzip .loading-spinner {
    display: none;
}
</style>


<script>
document.observe( 'dom:loaded', function() {

    $$( '#meetanshi-restrictzip .check-zip' ).invoke( 'observe', 'click', function( e ) {
        var the_zip_code = $( 'meetanshi-zip' ).value;
        if ( the_zip_code == '' ) {
            $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
            $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
            $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'block' }); } );
            $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'none' }); } );

            return;
        }

        $$( '#meetanshi-restrictzip .loading-spinner' ).each( function (e) { e.setStyle({ display: 'inline-block' }); } );
        $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
        $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
        $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'none' }); } );
        $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'none' }); } );

        // Send an AJAX request
        new Ajax.Request( meetanshi_restrictzip_ajax_url, {
            method: 'post',
            parameters: { zip_code: the_zip_code },
            asynchronous: true,
            onSuccess: function( response ) {
                var json_response = response.responseText.evalJSON();
                
                
                if ( json_response.status == 'success' ) {
                    if ( json_response.allowed_zip == true ) {
                        $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'block' }); } );
                        
                        $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                        $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                        $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                        
                        document.getElementById("extpected_delivery_time").innerHTML = "Estimated Delivery Time : "+json_response.estimate_delivery_time;                       
                    }
                    else {
                        $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                        $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'block' }); } );
                        $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                        $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                    }
                }
                else {
                    $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                    $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                    $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                    $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'block' }); } );
                }

                $$( '#meetanshi-restrictzip .loading-spinner' ).each( function (e) { e.setStyle({ display: 'none' }); } );
            },
            onException: function( request, ex ) {
                //alert( ex.toSource() );
            },
            onFailure: function() {
                $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'block' }); } );

                $$( '#meetanshi-restrictzip .loading-spinner' ).each( function (e) { e.setStyle({ display: 'none' }); } );
            }
        });


        e.stop();
    });

});

</script>

enter image description here

php – show contact form 7 in popup on button click

i have create a form using contact form 7 and now i want to show that as button click. spouse, i have Contact Us button, and while i will click to Contact Us button, it will open a popup with my created contact form 7 where i can use contact form shortcode. but i’m not understanding how i can do this? if there have to use any wordpress functions or plugin, please give me some instruction.

thanks.

plugins – (WP/Elementor/WPForms) how to fill form fields in an elementor popup when it opens via a button

I have created a popup with a WPforms-contact-form in it. Now i want, when the popup opens, that attributes of the button link prefill the form. I know it is possible to send link attributes on page load to a form – but it doesnt work on the popup. I need somekind of ID-data to be send to the form – so i am able to identify the specific button which was pressed (like some product-id). I already tried some jquery scripts but none of it is working and i dont know if this is the right/only way to fill a popup form with predefinded data.

I really hope i dont have to build for every link a specific popup :/

I hope you guys can understand my problem … i am no native english speaker.

Thanks a lot in advance

usability – One button with Multiple States that Change Label and Functionality

I am redesigning a site right now and have the following question.

Currently the user is presented with a list of Workstations. They have the option of:

  1. Adding additional workstation(s) to the list

enter image description here

  1. Selecting an existing workstation from the list and updating that existing workstation’s information

enter image description here

As you can see, the ADD button changes to UPDATE button when they select a workstation in the list (IE the label AND the functionality change.)

Is this something that could confuse the user? Would it be better to show both buttons at all times?

In other words, when the user is presented with the list of workstations, but has NOT selected one from the list, only the ADD button would be active?

enter image description here

Conversely, once the user HAS selected a workstation in the list by clicking on it, only the UPDATE button would be active?

enter image description here

I would welcome any and all feedback on this issue, including any good links for future use in determining best practices.

Much thanks in advance!!

px

magento2 – Move paper buttons from minicart to checkout step 2 under the Paypal payment button

When I turned on the paper on the site, they added paper buttons to me in the mini-cart.
enter image description here

Tell me how to move these buttons under the button on the checkout step 2.
There are a PayPal payment method and a process to checkout button.
I want these buttons to be under it with this button, how to implement it?

java – When the button is clicked it returns a message or displays it. Spring Boot

I’m fairly new spring boot and really trying to learn as much as possible. Currently, I’m creating simple vending machine web application. I was able to display the button but don’t know how to write out a code when the button is clicked it returns a message or popup window that says “You purchased a drink” or whatever message is suitable in this senario. Additionally, I’m incorporating Thymeleaf for this small project. I’m open for ANY suggestions and I’m pretty sure I’m writing my code wrong. Thanks!

So far in my Controller I have this:

@Controller

    @RequestMapping
    public class VendingMachineController {
    
        @GetMapping("/vending-machine")
        public String juice() {
            return "vending-machine";
        }
    
        @PostMapping("/vending-machine/")
        public String purchasedMessage(Model model){
            model.addAttribute("You've purchased an");
            return "/vending-machine";
        }
    }

And this is my html file:

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">
    <title>VendingMachine</title>
</head>
<body>


    <h2 class="title-name">Vending Machine</h2>
    <button type="submit" class="btn-buy-juice" name="purchase-btn" value="orange juice">Purchase orange juice</button>

</body>
</html>

Should I use multiple icon for two states of toggle button

I have a simple bar chart component and I’m going to add a button which help user able to switch between two view modes. Let say:

  • First mode called “relative view” (show percentage value of each column).
  • Second mode called “absolute view” (so actually number value of each column).

The button to toggle-like, but I want the UI is just a simple button, not using the switch. Default is “absolute view”.

I have two questions:

  • Should I use two different icons for each state according the current view mode? For example, one “number” icon, and one “%” icon.
  • If I use two different icons, the icon should be show according the “current state” or “next state”?

For second question, for example if I am currently in “absolute view”, should it be displayed “number” icon or “%” icon? Each way has its meaning I think:

  • If I use icon for next state, that mean I taught user: click to change to next state.
  • If I use icon for current state, that mean I taught user: this is the current state, click to toggle.

This thing makes a little considering. Any help should be highly appreciated. Thanks.

How can i modify the boot.img files so that when the power button and volume + is pressed during startup it doesnt start recovery but fastboot instead

Stack Exchange Network


Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Unable to click on this Button using selenium (java)

i have issues with click(); function using selenium webdriver.

here’s the outputHtml :

< button type=”button” class=”k-button k-primary” tabindex=”0″ style=”width: 50%;”>Valider< /button>

i used the findEelement using various xpath like :

  • “//button(@class = ‘k-button k-primary’ and @type = ‘button’)”
  • “//*(contains(@class, ‘k-button k-primary’) and text()=’Valider’)”

and still got the error Unable to locate the element

here’s the screenshot of the pop-up’s Button that i need to click on (button Valider)

Button : Valider