Q:

User input from editText to a String

I looks like a simple question, but i can't manage to get it to work.
I'm trying to make weather app, and im using Yahoo API, And like this the app works:
        service.refreshWeather("Dallas, TX");

I wanted to make the user input the city, so i made this:
    mButton = (Button)findViewById(R.id.mDugme);
    mEdit = (EditText)findViewById(R.id.unesiGrad);
    String userInput11;

    mButton.setOnClickListener(
            new View.OnClickListener()
            {
                public void onClick(View view)
                {
                     userInput11 = mEdit.getText().toString();
                }
            });

    service.refreshWeather(userInput11);

Why isn't it working?

A:

Take this code
mButton.setOnClickListener(
            new View.OnClickListener()
            {
                public void onClick(View view)
                {
                     userInput11 = mEdit.getText().toString();
                }
            });

    service.refreshWeather(userInput11);

and reorder it to look like this
mButton.setOnClickListener(
                new View.OnClickListener()
                {
                    public void onClick(View view)
                    {
                         userInput11 = mEdit.getText().toString();
                         service.refreshWeather(userInput11);
                    }
                });

It may demand to declare service as final. I am not sure. Just follow IDE instructions.

